科技知識動態:微信小程序之rich-text教程詳解

導讀跟大家講解下有關微信小程序之rich-text教程詳解,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說微信小程序之rich-text教程

跟大家講解下有關微信小程序之rich-text教程詳解,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說微信小程序之rich-text教程詳解,小編也收集到了有關微信小程序之rich-text教程詳解的相關資料,希望大家看到了會喜歡。

這篇文章主要介紹了 微信小程序 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}}" />

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' }], }] }]})

以上就是微信小程序之rich-text教程詳解的詳細內容,更多請關注php中文網其它相關文章!

來源:php中文網

免責聲明:本文由用戶上傳,如有侵權請聯系刪除!