关于 RichEditor 内容是否可以根据状态变量刷新的问题
已解决
关于 RichEditor 内容是否可以根据状态变量刷新的问题
示例代码:
testController: RichEditorController = new RichEditorController();
@Local testContent: string[] = [""]
build() {
...
RichEditor({controller: this.testController})
.onReady(()=>{
this.testContent.forEach(v=>this.testController.addTextSpan(v));
})
.backgroundColor(Color.Blue)
Button("改变内容").onClick(()=>{this.testContent.push("你好"); this.testContent[0] = "世界"})
...
}
类似于这种形式,点击按钮无法使 RichEditor 中的内容改变,我觉得合理又不合理,合理的地方是因为它是从方法中加载的内容,不合理的地方是 RichEdtor 这个组件只能这样通过属性方法加载内容导致不能根据状态变量刷新,看看老师能不能解决一下。
示例代码:
testController: RichEditorController = new RichEditorController();
@Local testContent: string[] = [""]
build() {
...
RichEditor({controller: this.testController})
.onReady(()=>{
this.testContent.forEach(v=>this.testController.addTextSpan(v));
})
.backgroundColor(Color.Blue)
Button("改变内容").onClick(()=>{this.testContent.push("你好"); this.testContent[0] = "世界"})
...
}
类似于这种形式,点击按钮无法使 RichEditor 中的内容改变,我觉得合理又不合理,合理的地方是因为它是从方法中加载的内容,不合理的地方是 RichEdtor 这个组件只能这样通过属性方法加载内容导致不能根据状态变量刷新,看看老师能不能解决一下。
1
浏览171 编辑于2025-09-28 02:18湖北
全部评论
最多点赞
最新发布
最早发布
写回答
所见即所得编辑器, editor1
工具栏
0/50000
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
- 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
- 如您发布的内容为转载内容,请注明内容来源。
我要提问题
了解社区公约,与您携手共创和谐专业的开发者社区。






































苏公安网备 32011402010933号