这是html代码结构,其中rich-text节点中nodes绑定的就是我们的内容
<rich-text nodes="{{html}}"></rich-text>
然后在page里面定义html这个参数(注意html类型为字符串)
data: {
html:''
},
最后在onload里面获取后端返回的数据,传给html,
success: (res) => {
console.log(res.data.rs)
this.setData({
html:res.data.rs.GoodContent
})
}
res.data.rs.GoodContent就是后端发送给我的数据,数据是这样的
GoodContent: "<p>这是套餐的详情介绍</p><p><img src="http://kaceduoxuanyi.oss-cn-beijing.aliyuncs.com/kfcs52691131907161059215921810/upload/day_200709/202007091157504621.jpeg" width="150" height="150" alt="" /><br /></p><p>主要是看一下效果</p>"
渲染到页面是这样的 :
这是套餐的详情介绍
主要是看一下效果