1***@qq.com
1***@qq.com
  • 发布:2022-12-08 17:01
  • 更新:2023-11-27 18:02
  • 阅读:794

【报Bug】editor组件使用setContents设置内容之后,光标不是在editor输入内容的最后,而是在内容的最前边

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 家庭中文版

HBuilderX类型: 正式

HBuilderX版本号: 使用的是vscode

第三方开发者工具版本号: 1.05.2110110

基础库版本号: 2.27.0

项目创建方式: HBuilderX

示例代码:

<editor id="editor" @ready="onEditorReady"></editor>

onEditorReady(){
this.$nextTick(() => {
uni.createSelectorQuery().in(this).select('#editor').context((res) => {
this.editorCtx = res.context
}).exec()
})
}

//选择用户之后进行如下操作
let text = '’
let userName = '用户名称'
text += <span> </span><span style="color: #245bdb;">@${userName}</span><span> </span>
this.editorCtx.setContents({
html:text
})

操作步骤:

<editor id="editor" @ready="onEditorReady"></editor>

onEditorReady(){
this.$nextTick(() => {
uni.createSelectorQuery().in(this).select('#editor').context((res) => {
this.editorCtx = res.context
}).exec()
})
}

//选择用户之后进行如下操作
let text = '’
let userName = '用户名称'
text += <span> </span><span style="color: #245bdb;">@${userName}</span><span> </span>
this.editorCtx.setContents({
html:text
})

预期结果:

光标应该在editor中的内容最后边

实际结果:

光标处于editor中的内容最前边

bug描述:

使用editor写@用户的功能,选择用户之后在editor里边插入这个@用户名称,这是后正常来说光标应该处于这个用户名称之后,但是这时候光标跑到了editor中内容的最前边,这样是不利于用户操作的

2022-12-08 17:01 负责人:无 分享
已邀请:

最佳回复

DCloud_UNI_WZF

DCloud_UNI_WZF

微信小程序设计如此,可以去微信小程序社区反馈
uniapp支持把vue语法的代码编译为小程序对应的文件

  • 3***@qq.com

    这个问题 app端也有,貌似也是没有处理,想使用setcontents进行文字回显后编辑,结果使用代码聚焦时候光标在最前面。

    2023-12-03 17:32

tank2015

tank2015

这个问题我也遇到了,20年的时候就有人在微信小程序社区反应bug了,现在好像都没有解决

顺小星

顺小星

2023年11月份了,该问题还是没有解决

r***@qq.com

r***@qq.com

遇到了一样的问题,请问解决了吗

要回复问题请先登录注册