微信小程序 rich-text

rich-text

  • 属性:nodes 类型:Array / String 结点列表 / HTML String
  • 全局支持class和style属性,不支持id属性。
  • 结点类型:type = node
    name 标签名 String 是 支持部分受信任的HTML结点
    attrs 属性 Object 否 支持部分受信任的属性,遵循Pascal命名法
    children 子结点列表 Array 否 结构和nodes一致
  • 结点类型:type = text
    text 文本 String 是 支持entities
  • nodes 不推荐使用 String 类型,性能会有所下降
  • rich-text 组件内屏蔽所有结点的事件。
  • attrs 属性不支持 id ,支持 class 。
  • name 属性大小写不敏感。
  • 如果使用了不受信任的HTML结点,该结点及其所有子结点将会被移除。
  • img 标签仅支持网络图片。
<rich-text nodes="{{nodes}}" />
<rich-text nodes="{{nodes1}}" />
<rich-text nodes="{{nodes2}}" />

这里写图片描述

this.setData({
    nodes: "<h1 style='color:red;'>html标题</h1>",
    nodes1: [{
      name: "h1",
      attrs: {
        style: "color:red",
        class: "red"
      },
      children: [{
        type: "text",
        text: '结点列表标题'
      }]
    }],
    nodes2: [{
      name: "ul",
      attrs: {
        style: "padding:20px;border:1px solid blue;",
        class: "red"
      },
      children: [
        {
          name: "li",
          attrs: {
            style: "color:red",
            class: "red"
          },
          children: [{
            type: "text",
            text: '多层结点 无序列表'
          }],
        }, {
          name: "li",
          attrs: {
            style: "color:red",
            class: "red"
          },
          children: [{
            type: "text",
            text: '多层结点 无序列表1'
          }],
        }]
    }]
})
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值