微信小程序和支付寶小程序富文本使用


微信小程序使用的是node

1.  wxml 頁面元素的最簡單使用
<rich-text nodes="{{這是你的數據}}"></rich-text>
 
2. js部分
以下能夠直接獲取

 

 


支付寶小程序

 

1. axml 頁面簡單使用
<rich-text nodes="{{nodes}}" ></rich-text>
 
2. js部分
 
import parser from 'rich-text-parser'    //這個文件是引用是關鍵下載地址: https://github.com/Chaunjie/rich-text-parser
Page({
data: {
     txte1: 「」,
     nodes: [],
},
onLoad(e) {
     let that = this
     let txte1 = e.txte
     // const {p} = that.data
  // 定義須要解析的特殊標籤,value不填默認是div
  // parser.definedCustomTag({figure: 'p', figcaption: ''})
  const nodes = parser.getRichTextJson(txte1)
        that.setData({
  nodes: nodes.children
  })
 },
});

 

 這些數據我是上一個頁面傳遞新來的git

首次記錄學習過程有不足之處請多見諒!!!
相關文章
相關標籤/搜索