如何把条件内函数的一个 dojo

plupiseo  于 2022-12-16  发布在  Dojo
关注(0)|答案(1)|浏览(150)

我可能无法解释dojo函数的头结构,但这是我正在寻找的这里是我现有的函数

createClient: function () {
            var clientWizardData = this.getNewClientWizardData(),

                clientSummaryFormData = clientWizardData.clientSummaryFormData,
                subscribedProducts = clientSubscriptionFormData.products,
                createClientRequest;

            createClientRequest = {
                "subscriptionMode": clientSubscriptionFormData.mode,
                "products": subscribedProducts,
                "subscriptionType": clientSubscriptionFormData.subscriptionType,
                "subscriptionStartDate": formatters.toVPDateBoundedJSON(clientSubscriptionFormData.subscriptionFromDate, true),
                "clientFinalised": clientSummaryFormData.isClientFinalise
            };
        },

我想把if条件放在createClientRequest函数中
条件是这样的

if(toggleableFeatures.has(globals.toggleableFeatures.INCLUDE_EXCLUDE_ALIASES_ALTERNATIVE_SPELLING)){
            "aliases": clientSubscriptionFormData.aliases,
            "alternativeSpelling": clientSubscriptionFormData.alternativeSpelling,
            "excludeLowQualityAkas": clientSubscriptionFormData.excludeLowQualityAkas,
            "includeNativeAkas": clientSubscriptionFormData.includeNativeAkas
    }else{
            "excludeLowQualityAkas": clientSubscriptionFormData.excludeLowQualityAkas,
            "includeNativeAkas": clientSubscriptionFormData.includeNativeAkas
    }

有人能帮我一下语法吗,直接输入if else不起作用,我必须创建任何函数然后调用它吗?

anauzrmj

anauzrmj1#

像这样试试

"clientFinalised": clientSummaryFormData.isClientFinalise,
                "if": {"toggleableFeatures": globals.toggleableFeatures.INCLUDE_EXCLUDE_ALIASES_ALTERNATIVE_SPELLING },
                "then": {"aliases": clientSubscriptionFormData.aliases,"alternativeSpelling": clientSubscriptionFormData.alternativeSpelling,"excludeLowQualityAkas": clientSubscriptionFormData.excludeLowQualityAkas,"includeNativeAkas": clientSubscriptionFormData.includeNativeAkas },
                "else": {
                    "excludeLowQualityAkas": clientSubscriptionFormData.excludeLowQualityAkas,
                    "includeNativeAkas": clientSubscriptionFormData.includeNativeAkas
                },
            };

相关问题