溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

小程序怎么使用rich-text

發布時間:2020-12-22 10:10:59 來源:億速云 閱讀:136 作者:小新 欄目:移動開發

這篇文章主要介紹小程序怎么使用rich-text,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

微信小程序 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}}" />

小程序怎么使用rich-text

this.setData({
  nodes: "<h2 style='color:red;'>html標題</h2>",
  nodes1: [{
   name: "h2",
   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'
     }],
    }]
  }]
})

以上是“小程序怎么使用rich-text”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女