0
我已加載第三方js文件到app.component這樣加載第三方JS文件角分量文件
declare var MarvinJS: any;
import { MarvinJS } from "../assets/js/marvinjslauncher.js";
我可以用它在我的應用程序組件類marvinjslauncher.js定義的方法,如果可以,請指導我如何使用?我試圖用這樣的:
export class AppComponent {
constructor() {
MarvinJS.MarvinJSUtil.getEditor("#sketch").then(function(sketcherInstance){
});
}
如果我輸入的方式是錯誤的,你可以請指導我。而我也包括marvinjslauncher.js文件到index.itml 我得到這個樣的錯誤:
ERROR TypeError: Cannot read property 'MarvinJSUtil' of undefined
at new AppComponent (eval at <anonymous> (bundle.js:1312), <anonymous>:16:39)
at createClass (eval at <anonymous> (bundle.js:321), <anonymous>:11007:26)
at createDirectiveInstance (eval at <anonymous> (bundle.js:321), <anonymous>:10841:37)
at createViewNodes (eval at <anonymous> (bundle.js:321), <anonymous>:12204:49)
at createRootView (eval at <anonymous> (bundle.js:321), <anonymous>:12109:5)
at callWithDebugContext (eval at <anonymous> (bundle.js:321), <anonymous>:13247:42)
at Object.debugCreateRootView [as createRootView] (eval at <anonymous> (bundle.js:321), <anonymous>:12707:12)
at ComponentFactory_.create (eval at <anonymous> (bundle.js:321), <anonymous>:10030:46)
at ComponentFactoryBoundToModule.create (eval at <anonymous> (bundle.js:321), <anonymous>:3633:29)
at ApplicationRef_.bootstrap (eval at <anonymous> (bundle.js:321), <anonymous>:5214:57)
?如果MarvinJS不是ES模塊,導入將不起作用。您必須通過'