繁体   English   中英

在SuiteScript 2.0中引用自定义AMD模块

[英]Referencing custom AMD Modules in SuiteScript 2.0

Netsuite表示在创建自定义模块时包括模块ID,如下所示:

define(module_id, [dependencies], function)

但是,当我执行该模块时,找不到:

TypeError: Cannot read property "XPELPCenterModule" from undefined (/path/to/mysuitelet.js#35)

当我删除I​​D时,它起作用了???

Hello Human Coder

我想念什么。 我用相同的方式称呼他们两个

function (ui, email, runtime, search, record, log, render, cache, crypto, file, pcenter) {
        var p = new pcenter.XPELPCenterModule();

.....

p.helloWorld('Human Coder');

以下是模块代码示例:

工作代码:

define(["require", "exports"],
function (require, exports) {

    var XPELPCenterModule = /** @class */ (function () {

        function XPELPCenterModule(name) {
            this.name = name;
        }

        XPELPCenterModule.prototype.helloWorld = function (name) {
            return 'Hello ' + name;
        };

        return XPELPCenterModule;
    }());

    exports.XPELPCenterModule = XPELPCenterModule;
});

非工作代码:

define('XPELPCenterModule', ["require", "exports"],
function (require, exports) {

    var XPELPCenterModule = /** @class */ (function () {

        function XPELPCenterModule(name) {
            this.name = name;
        }

        XPELPCenterModule.prototype.helloWorld = function (name) {
            return 'Hello ' + name;
        };

        return XPELPCenterModule;
    }());

    exports.XPELPCenterModule = XPELPCenterModule;
});

诀窍是使用@NAmdConfig并添加模块路径的.json配置文件:

/**
 *@NApiVersion 2.0
 *@NScriptType Suitelet
 *@NModuleScope Public
 *@NAmdConfig  /path/to/myModule.json
 */

.JSON配置文件:

{
  "paths": {
    "XPELPCenterModule": "/path/to/myModule"
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM