wangEditor内容赋值

接上文 ,https://blog.csdn.net/qq_39704057/article/details/119993871?spm=1001.2014.3001.5501

需要把已经存起来的内容在编辑器里面显示

关键代码

this.editor.txt.html(res.msg[0].content)

括号里面的值,就是存储起来的数据,根据个人的项目的字段不同,需要变化

完整代码

<el-form-item label="内容" class="block">
    <div id="addpagecontent"></div>
</el-form-item>

 

import E from 'wangeditor'
export default {
		data() {
			return {
				form:{},
			}
		},
		created() {
			this.selId()
		},
		methods: {
			selId(){
				//获取传递过来的id
				let id = this.id
				//根据id来查询数据
				articId(id).then(res =>{
					console.log(res.msg[0])
					this.form = res.msg[0] 
					this.editor = new E('#addpagecontent');
					this.editor.create(); //创建富文本编辑器
					this.editor.config.zIndex = 50
					this.editor.txt.html(res.msg[0].content)  //编辑器内容
				})
			},
		}
	}

效果

 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值