当前位置:网站首页>Baidu applet rich text parsing tool bdparse

Baidu applet rich text parsing tool bdparse

2022-06-26 09:03:00 CMS applet plug-in [official]

Recently doing Baidu applet , It is found that Baidu applet is rarely contacted at present , I can't find the relevant technical support , In particular, rich text processing tools for handling articles . Anyone who has done a wechat applet knows , Wechat has a wxParse, A set of components specially developed for wechat rich text , Can make html A node that is converted into an applet , So I wondered if I could wxParse Transformed into Baidu applet .

Because the code similarity between Baidu applet and wechat applet is larger 95% above , Almost wechat wxml,js Request and label batch replacement with Baidu swan,js Of ,css and json Completely universal , This also includes rich text nodes exactly the same , So try to transform , The cycle used for Baidu and wechat is different from the template call , So it took some time , In order to distinguish between wxParse, So change your name bdParse.

bdParse Project download address :https://gitee.com/sootou/bdparse

Project introduction

Baidu applet rich text parsing tool bdParse, Remodel from wxparse, Support html Convert to Baidu applet rich text node .

Installation tutorial

  1. Download the entire file , Put it in your applet root directory
  2. On the applet page js Direct introduction of code :var bdParse = require('../../bdParse/bdParse.js'); Corresponding css Introduction in @import "../../bdParse/bdParse.css";
  3. Use... In the required fields baparse, Code :( Be careful :article and content Don't repeat )that.setData({ content:bdParse.bdParse('article', 'html', content, that, 5), })
  4. swan Page import template ,<import src="../../bdParse/bdParse.swan" />  Then call... Where you need to display rich text :<template is="bdParse" data="{ { {bdParseData:article.nodes} }}" /> ( Be careful :data The call is changed to and wxParse Consistent writing , Notice the three braces , The original direct writing { {article}} No longer supported , Please pay attention to the modification )

Instructions

  1. swan Calling the template data="{ { {bdParseData:article.nodes} }}" and setData Medium article bring into correspondence with .
  2. call bdparse Component time , The component has assigned the rich text content ( namely setData) Give it to article;{ { {bdParseData:article.nodes} }} This way of writing means : hold article.nodes The content of is assigned to bdParseData,bdParse.swan What is called is bdParseData.

Other instructions

  1. bdParse Is in wxParse On the basis of , Just put wxParse Replace with bdParse, contain js,swan, css
  2. wxml Change the suffix to swan, In addition, the calling method of all template value transfer has been modified , Conform to the use of Baidu applet .
  3. Fixed proprietary components of other Baidu applets , such as s-for,s-if,s-elif,s-for-index wait
  4. Fix other problems , For example, remove <template name="wxParseImg"> Repetitive mode, To all s-for-index add to idx( It seems that it cannot be empty ).
  5. Other modifications , I won't repeat
  6. Because the content is replaced directly in batches , Basic articles can meet the needs of , Others have not done much testing , Welcome your feedback bug

Participation and contribution

It's not easy , Support a lot

If you think bdParse Helped you solve the problem , Please don't forget to reward , Your support is our biggest motivation .

原网站

版权声明
本文为[CMS applet plug-in [official]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260838406870.html