在我的角8应用程序中使用tinyMCE并获得错误:
ReferenceError:没有定义tinymce
component.ts
declare const tinymce: any; // outside the class
ngAfterViewInit() { // inside the class
tinymce.init({
selector: 'tinymce',
height: 300,
menubar: false,
plugins: 'link lists paste image',
toolbar: 'undo redo | formatselect | bold italic backcolor link image | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat'
});
}component.html
<editor #tinymce id="tinymce" apiKey="mykeyishere" formControlName="article"></editor>我试图从组件而不是模板中调用tinymce上的init(),因为我无法在模板中(从官方文件)这样做:
/* without images_upload_url set, Upload tab won't show up*/
images_upload_url: 'postAcceptor.php',
/* we override default upload handler to simulate successful upload*/
images_upload_handler: function (blobInfo, success, failure) {
setTimeout(function () {
/* no matter what you upload, we will turn it into TinyMCE logo :)*/
success('http://moxiecode.cachefly.net/tinymce/v9/images/logo.png');
}, 2000);
}我需要在组件中定义自定义上传图像处理程序,但是TinyMCE角度的文档只覆盖从模板调用init的用例,因此在文档中处理图像上传时没有解决方案。
我做错了什么?
发布于 2020-09-21 09:13:57
我也遇到了同样的问题,使用了角10。我通过在index.html的头中添加这个脚本来修正它:
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.4.2/tinymce.min.js"></script>我在这里找到了src链接:
https://cdnjs.com/libraries/tinymce。
关于信息,我使用的是IntelliJ终极。声明脚本之后,IntelliJ建议我下载脚本src库。我希望这能对将来的人有所帮助。
https://stackoverflow.com/questions/61686486
复制相似问题