javascript - Javascript 库不返回全局变量/定义
问题描述
我只是想就我的问题寻求帮助,我有一个外部 JS 库,目前它在 html 的标签内时工作,但是当我尝试将它合并到我的工厂函数中时,你可以在网络中看到它有已读取但当您尝试使用未定义的全局变量时,全局变量为 FlowchartLayout。
这是外部 JS 库的片段,我尝试将其设为 UMD 模块
(function (root, factory) {
if (typeof exports === 'object') {
// CommonJS
module.exports = factory(require('b'));
} else if (typeof define === 'function' && define.amd) {
// AMD
define(['b'], function (b) {
return (root.returnExportsGlobal = factory(b));
});
} else {
// Global Variables
root.returnExportsGlobal = factory(root.b);
}
}(this, function (b) {
'use strict';
function FlowchartLayout() {
go.Layout.call(this);
this._angle = 90;
this._nodeSpacing = 40; // between nodes in same layer
this._layerSpacing = 40; // between nodes in different layers
this._laneProperty = "lane"; // name of data property that identifies lane as a unique number or a string
this._laneComparer = null; // function for sorting FlowchartLanes
this._reset();
}
go.Diagram.inherit(FlowchartLayout, go.Layout);
/*The rest of the code of FlowchartLayout*/
return FlowchartLayout;
}));
任何帮助将不胜感激。谢谢你!
解决方案
推荐阅读
- tensorflow - 如何在图像上使用优化器应用损失
- python - 对 xml 节点进行排序
- oracle - Oracle12:lpad 函数不像 Oracle11 那样管理 2 字节字符
- pytorch - Weights&Biases Sweep - 为什么运行可能会相互覆盖?
- c++ - 类成员时无法调用 EnumWindows 函数
- python - discord.py 中的命令冷却时间
- image - 转换&Vec
RGB 数据到 ImageBuffer Rust - python - quiver3用圆柱体代替matlab中的箭头
- codeigniter-4 - Codeigniter 4 模型关系实体
- javascript - DataTable中的值被切换