wangeditor-team / wangEditor

wangEditor —— 开源 Web 富文本编辑器
http://www.wangeditor.com/
MIT License
17.37k stars 3.31k forks source link

在Nuxt3,vue3中使用报错 #5296

Open ushier opened 1 year ago

ushier commented 1 year ago

问题描述

按照vue方式接入后,在nuxt环境下会报错“Element is not defined”,

image

wangEditor 版本

"@wangeditor/editor": "^5.1.23", "@wangeditor/editor-for-vue": "^5.1.12",

是否查阅了文档 ?

是,已经查阅过文档,未解决问题。

最小成本的复现步骤

image
ushier commented 1 year ago

第一次进入这个页面,wangeditor可以正常展示,刷新页面之后,就会提示“Element is not defined” ![Uploading image.png…]()

hanpandeng commented 1 year ago

nuxt3 文档里面关于客户端组件的介绍可以解决这个问题; image

phcent commented 1 year ago

在plugins下创建wangEditor.client.ts

import { defineNuxtPlugin } from "#app";
import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
import "@wangeditor/editor/dist/css/style.css";
export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.component('Editor',Editor).component('Toolbar',Toolbar);
});
weijiang1994 commented 1 year ago

nuxt3 文档里面关于客户端组件的介绍可以解决这个问题; image

nuxt2 能用吗?这个问题

weijie-he commented 7 months ago

在plugins下创建wangEditor.client.ts

import { defineNuxtPlugin } from "#app";
import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
import "@wangeditor/editor/dist/css/style.css";
export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.component('Editor',Editor).component('Toolbar',Toolbar);
});

感谢,这边只能用 vueApp.component 注册,我之前用了 vueApp.use 不行

Thinker-feiluo commented 2 months ago

@ushier 解决没有,我也遇到同样的问题