问题描述
我正在尝试在AngularJS [v 10]打字稿对象中使用自定义Java Script类。但无法使用与之相同的错误并得到
错误ReferenceError:未定义
这是我的代码
JavaScript simple-image.js文件
export class SimpleImage {
constructor() {
}
render(){
return document.createElement('input');
}
}
"scripts": [
"src/assets/simple-image.js"
]
使用app.component.ts中的JavaScript文件
import { Component } from '@angular/core';
import EditorJs from '@editorjs/editorjs';
import Header from '@editorjs/header';
declare var SimpleImage:any;
@Component({
selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'editor-example';
public editor: any;
ngOnInit(): void {
this.editor = new EditorJs({
holderId: "contentpart",autofocus: true,tools: {
header: {
class: Header,inlinetoolbar: ['link'],config: {
placeholder: 'Header'
}
},image: {
class: new SimpleImage(),}
},/**
* onReady callback
*/
onReady: () => {
alert('Editor.js is ready to work!')
}
}),this.editor.isReady
.then(() => {
console.log('Editor.js is ready to work!')
/** Do anything you need after editor initialization */
})
.catch((reason) => {
console.log(`Editor.js initialization Failed because of ${reason}`)
});
}
}
我在控制台中遇到以下错误
ERROR ReferenceError: SimpleImage is not defined
ngOnInit app.component.ts:38
Angular 24
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)