Method for displaying HTML format content in WeChat applet

What is the method of displaying HTML format in the WeChat applet? This issue may be often seen in our daily study or work. I hope that you can give you a deep harvest through this issue. Below is the reference content brought by Xiaobian, let’s take a look!

Recent items encountered in WeChat applets need to display news content, news content is the rich text content in the server read through the interface, is In the HTML format, the applet default is the content displayed by the HTML format, then we need to display the HTML content, you can implement it through wxparse.

Preparation:

First we download WXPARSE

GitHub Address: https: //github.com/icindy/ WXPARSE

Local download: http://xiazai.jb51.net/201704/yuanma/wxparse-master (jb51.net) .rar

在微信小程序中显示html格式内容的方法 wxparse

After downloading, we need to use the WXPARSE folder in the directory, copy him into our project directory

在微信小程序中显示html格式内容的方法 The following is the specific use steps

1, in the app.wxss global style file, you need to introduce WXPARSE style table

@Import “/page/wxss/wxparse.wxss”
 2, in the JS file that needs to load the HTML content, WXPARSE   
var wxparse = request (‘../ . ../wxparse/wxparse.js’);

3, by calling WXPArse.WxParse method to set HTML content   
/ *** WXPARSE.WXPARSE (BindName, Type, Data, Target, ImagePadding) * 1. Bindname Binding data name (required ) * 2.Type can be HTML or MD (required) * 3.Data is incoming specific data (required) * 4.Target is Page object, generally this (required) * 5.ImagePadding is a picture Adaptive is a single Padding (default is 0, optional) * /

  PAGE ({DATA: {}, ONLOAD: function () {var That = this; wx.Request ({URL: ', Method:' POST ', DATA: {' ID ': 13}, header: {' content-type ':' Application / Json '}, Success: Function RES) {var article = res. Data [0] .post; wxparse.wxparse ('Article', 'HTML', Article, That, 5);}}}}})  
4, Template
   

   can be embedded in the WeChat applet.   
Thank you for reading! After reading the above, do you know about the method of displaying the HTML format content in the WeChat applet? I hope that the content of the article will help everyone. If you want to know more about the content, please pay attention to TumiCloud Industry Information Channel.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment