Yog*_*lav 3 webpack quill vue.js laravel-5
我目前正在使用 vue2-editor 并导入 quill 模块并按照文档注册它们。但是出现错误 window.Quill 未定义。
我尝试过使用 webpack 插件组合来包含 window.Quill 和 Quill,但错误仍然存在。
在我的 vue 组件中
import { VueEditor } from "vue2-editor";
import { Quill } from "quill";
import { ImageDrop } from "quill-image-drop-module";
import { ImageResize } from "quill-image-resize-module";
Quill.register("modules/imageDrop", ImageDrop);
Quill.register("modules/imageResize", ImageResize);
Run Code Online (Sandbox Code Playgroud)
在我的 webpack 组合中
mix.extend('foo',new class{
webpackPlugins(){
return new webpack.ProvidePlugin({
"window.Quill": "quill/dist/quill.js",
Quill: "quill/dist/quill.js"
});
}
});
Run Code Online (Sandbox Code Playgroud)
未捕获的类型错误:无法读取未定义的属性“导入”
来自 window.Quill.imports
您需要从https://www.jsdelivr.com/package/npm/quill-image-resize-vue获取真正的工作文件:
只需安装 npm i --save quill-image-resize-vue 并使用另一个文件:
import { VueEditor,Quill } from 'vue2-editor'
import ImageResize from 'quill-image-resize-vue';
import { ImageDrop } from 'quill-image-drop-module';
Quill.register("modules/imageDrop", ImageDrop);
Quill.register("modules/imageResize", ImageResize);
export default {
name: 'MainForm',
components: { VueEditor},
data() {
return {
content: '<h2>I am Example</h2>',
editorSettings: {
modules: {
imageDrop: true,
imageResize: {},
}
}
}
},
//........
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3249 次 |
| 最近记录: |