微信小程序之富文本解析

微信小程序之富文本解析_第1张图片

2、在项目文件中使用
(1)在需要使用的wxml文件中引入WxParse.wxml
示例:


<import src="../../wxParse/wxParse.wxml" />

(2)在当前页对应的js中引入wxParse.js
示例:

//index.js 
const WxParse = require('../../wxParse/wxParse.js');

(3)使用template组件
在刚刚引入的wxml中插入组件,具体插入的位置是需要转换的地方。
示例:


<import src="../../wxParse/wxParse.wxml" />
<view class="container">
  <view class='uinn'>
    <template is="wxParse" data="{{wxParseData:article.nodes}}" />
  view>
view>

(4)在当前页的js中使用WxParse中的方法

//index.js
const WxParse = require('../../wxParse/wxParse.js');
Page({
  data: {
    
  }, 
  onLoad: function () {
    let that = this;
    let ceshi = 
    `
请说出你喜欢的水果?
  • 苹果
  • 香蕉
  • 橙子
`
; WxParse.wxParse('article', 'html', ceshi, that, 5); }, })
微信小程序之富文本解析_第2张图片




你可能感兴趣的:(微信小程序)