2017-04-14 30 views
1

我在SS2中编写了一个脚本,并且遇到了一个声明我应该执行以下操作的文档。我已经完成了这一步,路径是正确的,但它似乎并没有看到下划线,因为它在尝试使用它时会回到未定义状态。任何帮助,这将是巨大的,谢谢 define([ 'N/email' , 'N/runtime' , 'N/search' , '/SuiteScripts/af_scripts/[email protected]/underscore' ], function(email, runtime, search, _) { function onRequest(context) {在SuiteScript 2中使用Underscore

 var request = context.request; 

     var us = _; 
    } 

    return { 
     onRequest: onRequest 
    }; 
}); 

回答

1

我还没有看到如何做到这一点。但我发现,作品的方式是这样的:

/** 
* @NApiVersion 2.x 
* @NScriptType usereventscript 
*/ 
require.config({ 
    paths:{ 
    "coolthing":"/SuiteScripts/myFavoriteJsLibrary" 
    } 
}); 
define(['coolthing'],function (coolthing){ 
    return { 
    beforeLoad:function beforeLoad(ctx){ 
     coolthing.times(2,function(){ 
     log.debug('log','log'); 
     }); 
    } 
    }; 
}); 
+1

谢谢,足够接近。我还发现使用非AMD模块的垫片的参考,谢谢你的帮助 – jk121960