有人可以告诉我如何更改requirejs定义:
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory(root));
} else if (typeof exports === 'object') {
module.exports = factory(root);
} else {
root.someVariable = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
'use strict';
var $someVariable = {},
someAnotherVariable = 'bla bla bla',
....
var someFunction = function(someVar) {
}
...
return $someVariable;
});
类似:
var someVariable = callAllInsideAndReturnVariableValue(title, message);
详细信息。尝试将此JS(https://github.com/dolce/izitoast/blob/master/master/dist/js/izitoast.js)移至简单函数,如前所述。
或可能有人知道如何在SAP UI5中使用此JS?SAP Design Studio(业务对象)
中的详细信息非常感谢您的任何帮助!
介绍一个工厂,以正确初始化您的模块代码。
if (typeof define === 'function' && define.amd) {
define([], factory(root)); //initialized through AMD
} else if (typeof exports === 'object') {
module.exports = factory(root)//initialized module loader,see: commonjs
} else {
root.someVariable = factory(root);//initialize to windows/global
}
我找到了解决方案,这是如何将requirejs lib附加到DS组件的帖子:https://blogs.sap.com/2016/04/15/your-first-extension-part-13-includejs/
以防万一也需要这样的解决方案:)