小程序富文本轉換


富文本編輯器可以不引用wxss,可以省略

1.index.js

var WxParse = require('../../utils/wxParse/wxParse.js');
 
//請求接口 獲取到對應的字段 var parma =
 id: that.data.id } wx.request({ url: app.globalData.url + "******", data: parma, header: { 'content-type': 'application/x-www-form-urlencoded' // 默認值
 }, method: 'POST', success: function (res) { console.log(res) // console.log(res.data.data.effect_pic)
 console.log(res.data.data.info) if (res.data.code == 1) {  that.setData({ info: res.data.data.info,//店鋪詳情
 }) 

      // 富文本轉換 放在that.setData下面 防止頁面還沒加載完
          var article = res.data.data.info; WxParse.wxParse('article', 'html', article, that, 5); 
      或者
          WxParse.wxParse('article', 'html',res.data.data.info, that, 5);
 
} }, }) 

 

2.index.wxss  此處可以省略
@import "/utils/wxParse/wxParse.wxss";
3.index.wxml
<import src="/utils/wxParse/wxParse.wxml" />
 <view class='box'> 
      <template style='width:100%;' is="wxParse" data="{{wxParseData:article.nodes}}" />
    </view>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM