微信小程序 rich-text 富文本标签

属性类型默认值必填说明最低版本
nodes array/string [] 节点列表/HTML String 1.4.0
space string   显示连续空格 2.4.1

 

 

 

主要通过  nodes 来接受,然后显示的代码显示,例:

 

 

代码多的话,可以在JS中直接 data中取出:{{}} 值绑定即可,

 

下面介绍 接受  对象数组 写法:

Page({
  
  data: {
    nodes: [{
      //1.标签名 用name定义
      name: 'div',
      //2.属性用attrs 定义
      attrs: {
        class: 'div_class',
        style: 'line-height: 60px; color: #1AAD19;'
      },
      //子节点用children定义
      children: [{
        type: 'text',
        text: 'I Love XIanYu  OK!'
      }]
    }]
  }
})

 

posted @ 2021-09-06 22:18  咸瑜  阅读(728)  评论(0编辑  收藏  举报