mengxinxuexi
mengxinxuexi
  • 发布:2021-06-09 16:29
  • 更新:2021-09-12 09:03
  • 阅读:1004

【报Bug】editor插入图片,执行多次input事件

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Win10

HBuilderX类型: 正式

HBuilderX版本号: 3.1.17

手机系统: Android

手机系统版本号: Android 10

手机厂商: OPPO

手机机型: oppo a3

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<template>  
    <view>  
        <editor id="editorId" @ready="onEditorReady" @input="bingEditorInput"></editor>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                editorCtx:null  
            }  
        },  
        methods: {  
            onEditorReady:function(){  
                uni.createSelectorQuery()  
                    .select('#editorId')  
                    .context(res => {  
                        console.log(res.context);  
                        this.editorCtx = res.context;  
                        this.insertImageFun();  
                    })  
                    .exec();  
            },  
            insertImageFun:function(){  
                this.editorCtx.insertImage({  
                    src: "/static/e415.png",  
                    width: '25px',  
                    height: '25px'  
                });  
            },  
            bingEditorInput:function(e){  
                console.log("bingEditorInput()")  
                console.log(e.detail.html);  
            }  
        }  
    }  
</script>  

<style>  

</style>

操作步骤:

直接运行示例中的代码

预期结果:

只执行一次bingEditorInput方法

实际结果:

只执行3次bingEditorInput方法,并且每次输出的html代码都不一样,第一次是<img src="图片地址">,第二次是<img src="图片地址" width="25px">,第三次是<img src="图片地址" width="25px" height="25px">

bug描述:

<editor id="editorId" @ready="onEditorReady" @input="bingEditorInput"></editor>

1.初始化editor
uni.createSelectorQuery().select('#editorId')
.context(res => {
this.editorCtx = res.context;
}).exec();

2.插入图片
this.editorCtx.insertImage({
src: "/static/e415.png",
width: '25px',
height: '25px'
});

3.监听内容改变,发现插入图片时,在insertImage()中每添加一个参数,就执行一次监听事件bingEditorInput()。

2021-06-09 16:29 负责人:无 分享
已邀请:
DCloud_UNI_LXH

DCloud_UNI_LXH

bug已确认,预计下版修复

  • y***@qq.com

    你好,新版本并没有修复这个问题呀。

    2021-09-12 09:02

y***@qq.com

y***@qq.com

楼主,问题解决了吗,我看新版并没有修复这个问题吧。

  • DCloud_UNI_LXH

    是修复了的,你用的什么版本?

    2021-09-14 15:20

  • y***@qq.com

    回复 DCloud_UNI_LXH: 您好,刚看了下已修复了哈,但是编缉器这块还有一个bug,具体请看这个帖子:https://ask.dcloud.net.cn/question/106391

    2021-09-14 19:06

该问题目前已经被锁定, 无法添加新回复