小程序中使用富文本

1.下載插件wxParse:https://github.com/SuperDalu/wxParse.githtml

2.放在小程序根目錄下node

3.在須要用到的頁面中插入git

<import src="../../wxParse/wxParse.wxml"/>
<view class="offer-detail">
  <template is="wxParse" data="{{wxParseData:article.nodes}}"/>
</view>

4.在當前頁面的js文件中github

var WxParse = require('../../wxParse/wxParse.js');
onLoad: function (options) {
      var that = this;
    var htmlTpl = '<p>某某某先生:</p ><p><br></p ><p>謹表明XXX公司,真誠歡迎您加入&nbsp;研發部&nbsp;任 技術總監。</p ><p><br></p ><p>請您於 2019年 3 月 1日(星期五)上午9:00,攜帶如下物品,到 某某某地點處辦理報到手續。</p ><p><br></p ><p>一、居民身份證原件及複印件4張;</p ><img src="http://b.zcjsny.top//img/boy.png"></img>';

      WxParse.wxParse('article', 'html', htmlTpl, that, 5);

  },

頁面就已經能夠顯示了,這是測試用的,實際中將文本換成從後臺獲取來的數據便可小程序

相關文章
相關標籤/搜索