vue中ueditor初始化无法编辑报错“$EDITORUI is not defined“

vue中使用ueditor初始化时最好使用组件vue-ueditor-wrap,下载的ueditor文件夹直接放在public文件夹下。

安装好vue-ueditor-wrap后,需要在main.js中注册

import VueUeditorWrap from 'vue-ueditor-wrap'
window.commonComponent = { VueUeditorWrap };

以上步骤可在页面中初始化出编辑器。

但是在分布式系统中使用ueditor,会出现编辑器无法编辑,F12中报错"$EDITORUI is not defined",at HTMLDivElement.onmouseover(或onmouseout)。这个问题常规方式查找时需要引用jquery,引用的jquery,还是没有解决以上问题。并且网上也找不到相关问题的解决方案。

方案一:

页面的mounted中加载setClass()方法:

setClass() {
            let myDiv = document.getElementById('edui_fixedlayer');
            let clasName = document.getElementsByClassName("v-modal");
            this.setInt1 = setInterval(() => {
                if (myDiv != null) {
                    if (myDiv.style.zIndex != '999999') {
                        myDiv.style.zIndex = "999999"

                    }
                }
                //console.log(this.setInt1);
            }, 200)
            this.setInt2 = setInterval(() => {
                if (clasName != null && clasName.length > 0) {
                    if (clasName[0].style.zIndex != 9) {
                        clasName[0].style.zIndex = 9
                    }
                }
            }, 1000)
        },

最后看到同事解决了,是编辑器被挡住了。设置ueditor在最外层。就能正常编辑。

方案二:

qiankun前端框架主应用和子应用的情况。把ueditor文件夹直接放在主应用的public文件夹里。发布后的直接放在根目录,与index.html同级。

主应用同样需要安装vue-ueditor-wrap组件后,需要在main.js中注册

import VueUeditorWrap from 'vue-ueditor-wrap'
window.commonComponent = { VueUeditorWrap };

在子应用中,同样安装了vue-ueditor-wrap,子应用也放置了ueditor文件夹。但是编辑器无法使用,使用以下方法在页面初始化中,可以使编辑器可以编辑。

setEnable(){
            //this.$refs.myueditor.setEnabled()
            document.getElementById('ueditor_0').contentWindow.document.getElementsByTagName('body')[0].contentEditable = true
        },
        setDisable(){
            //this.$refs.myueditor.setDisabled()
            document.getElementById('ueditor_0').contentWindow.document.getElementsByTagName('body')[0].contentEditable = false
        }

用这个方式有个问题,我的编辑器的工具栏无法使用,鼠标移上去还是报错。F12分析页面dom结构,发现ueditor的js引用都被注释掉了。出现<!-- <script dynamic   type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>  replace by qiankun-->

找网上的资料,说是子应用的使用方式不对,调整组件引用

components: {
        VueUeditorWrap: window.__POWERED_BY_QIANKUN__ ? window.commonComponent.VueUeditorWrap : VueUeditorWrap
    },

调用主应用中的VueUeditorWrap,确保路径读取到,也能动态使用。

终于清净了,没有报错了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值