国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點 > 微信 > 正文

微信小程序rich-text富文本用法實例分析

2024-07-22 01:18:23
字體:
供稿:網(wǎng)友

本文實例講述了微信小程序rich-text富文本用法。分享給大家供大家參考,具體如下:

rich-text是一個新增的微信小程序插件,從基礎(chǔ)庫1.4.0開始,低版本需要做兼容處理

nodes屬性可為Array和String類型,但推薦使用Array.由于String類型最終也會轉(zhuǎn)為Array類型

nodes分為支持兩種節(jié)點,分別為元素節(jié)點(type=node ,默認為元素節(jié)點)和文本節(jié)點(type=text)

元素節(jié)點

name 標簽名 String 支持部分受信任的HTML節(jié)點
attrs 屬性 Object 支持部分受信任的屬性,遵循Pascal命名法
children 子節(jié)點列表 Array 結(jié)構(gòu)和nodes一致

<!-- rich-text.wxml --><rich-text nodes="{{nodes}}" bindtap="tap"></rich-text><!--{{nodes}}其中的變量名與data中名字相同--><!--支持默認事件tap、touchstart、touchmove、touchcancel、touchend和longtap-->
// rich-text.jsPage({ data: { nodes: [{ name: 'div', attrs: { class: 'div_class', style: 'width : 100px; height : 100px; color: red;' }, children: [{ type: 'text', text: 'Hello World!' }] }] }, tap() { console.log('tap') }})

如果頁面中存在多個富文本,富文本中存在多個孩子,請看下例:

<!-- rich-text.wxml --><rich-text nodes="{{nodes}}"></rich-text><rich-text nodes="{{nodes1}}"></rich-text>
// rich-text.jsPage({ data: { nodes: [{ name: 'div', attrs: { class: 'div_class', style: 'width : 100px; height : 100px; color: red;' }, children: [{ type: 'text', text: 'Hello World!' }] }], nodes1: [{ name: 'p', attrs: { class: 'p_class', style: 'text-align : center; color: green;' }, children: [{ type: 'text', text: '我是p標簽!!!' },{ name: "span", attrs: {  style: "color:red",  class: "span_class" }, children: [{  type: "text",  text: '我是span標簽,哈哈哈哈' }] }] }] },})

文本節(jié)點

text 文本 String 支持entities

<!-- rich-text.wxml --><rich-text nodes="{{nodes}}"></rich-text>
// rich-text.jsPage({ data: { nodes: "我是文本節(jié)點,意外不?" },})            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 阿克| 彭泽县| 房产| 兴化市| 青铜峡市| 和龙市| 望都县| 阳信县| 体育| 阜阳市| 新竹县| 永和县| 突泉县| 海盐县| 长丰县| 长春市| 府谷县| 岳阳市| 静安区| 长白| 永定县| 通山县| 塔城市| 凌海市| 雷波县| 呈贡县| 娱乐| 堆龙德庆县| 锦州市| 普洱| 巴里| 友谊县| 乌拉特后旗| 怀安县| 盐源县| 科技| 永年县| 龙岩市| 大余县| 萨迦县| 本溪|