我使用Laravel 8和Laravel,以便我的JS资产与webpack一起编译。
通过这样做,我成功地导入了gojs:
npm i gojs然后将其添加到我的bootstrap.js中
import * as go from 'gojs';然后使用以下方法编译:
npm run dev到目前为止,我的app.js已经包含了gojs代码,并且我可以在页面上运行基本的gojs示例。
但是,我不知道如何包含任何gojs扩展。
我尝试以所有这些不同的方式向我的boostrap.js添加一个扩展(单独的,而不是一次性的):
import DataInspector from 'gojs/extensions/DataInspector.js';
import * as Inspector from 'gojs/extensions/DataInspector.js';
import { DataInspector } from 'gojs/extensionsTS/DataInspector';
require('gojs/extensions/DataInspector.js');
require('../../node_modules/gojs/extensions/DataInspector.js');大多数编译都没有错误,当我检查我的app.js编译的javascript时,DataInspector代码似乎包括在内。
但是,当我向使用检查的页面添加一个示例脚本时,我得到了错误:
Uncaught ReferenceError: Inspector is not defined因此,似乎没有包括DataInspector扩展。让它工作的唯一方法是直接将脚本标记添加到我的DataInspector.js文件中。不过,我想弄清楚如何用我的所有其他资产正确地导入它。
发布于 2021-04-13 13:54:04
最好将扩展名文件复制到您自己的目录中使用它们。它们是作为如何扩展库的示例提供的,不应该直接导入。
如果您查看扩展代码,您将看到它带有以下警告:
/*
* This is an extension and not part of the main GoJS library.
* Note that the API for this class may change with any version, even point releases.
* If you intend to use an extension in production, you should copy the code to your own source directory.
* Extensions can be found in the GoJS kit under the extensions or extensionsTS folders.
* See the Extensions intro page (https://gojs.net/latest/intro/extensions.html) for more information.
*/https://stackoverflow.com/questions/67076007
复制相似问题