簡體   English   中英

我們可以在define函數中包含第三個參數嗎?

[英]Can we include a third parameter inside define function?

我在RequireJS中看到了代碼,其中define()包含依賴模塊和回調函數以外的第三個參數。 我們可以在define函數中包含第三個參數嗎? 碼:

define("app/tmpl/mainTmpl", ["ax/ext/ui/Button",
                  "ax/ext/ui/Label", "ax/ext/ui/Layout"], 
    function (Button, Label, Layout) {
        return function () {
            return {
                //some code
            };
        };
    });

示例代碼中的第一個參數是模塊名稱 (AKA模塊ID),您可以選擇將其傳遞給define() 通常情況下,不建議顯式設置名稱。 如果省略,則名稱由AMD加載程序推斷和分配,或者可以由RequireJS的優化工具生成。 請參閱官方RequireJS API文檔或AMD API規范的 本部分

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM