项目场景:
进入页面初始化时,需要填入之前预填写的富文本内容,使用uniapp中editor组件setContents方法为富文本编辑器设置内容时,内容有时不时设置不成功,微信小程序同样适用
问题描述
使用uniapp中editor组件setContents方法为富文本编辑器设置内容时,在mounted时调用setContents方法,富文本内容有时设置不成功
样例代码:
<template>
<editor id="editor"></editor>
</template>
<script>
export default {
data() {
html: '<p>富文本测试</p>',
editorCtx : ''
},
mounted() {
let _this = this
// #ifdef APP-PLUS || H5 ||MP-WEIXIN
uni.createSelectorQuery().select('#editor').context((res) => {
_this.editorCtx = res.context //uni.createSelectorQuery获取editor 组件对应的 editorContext实例
}).exec()
_this.editorCtx.setContents({
'html': _this.html,
success: (res)=> {
console