当前位置:网站首页>百度小程序富文本解析工具bdParse
百度小程序富文本解析工具bdParse
2022-06-26 08:38:00 【cms小程序插件【官方】】
最近在做百度小程序,发现百度小程序目前大家接触的都比较少,还搜不到相关的技术支持,特别是处理文章的富文本处理工具。做过微信小程序的都知道,微信有一个wxParse,专门针对微信富文本开发的一套组件,可以完美让html转换成小程序的节点,于是便想能不能把wxParse改造成百度小程序的。
由于百度小程序和微信小程序的代码相似度搞大95%以上,几乎就是微信的wxml,js请求和标签批量替换成百度swan,js的,css和json完全通用,这也包括富文本节点完全一样,所以尝试改造,用于百度和微信的循环和模板调用不太一样,所以也费了点时间,为了区分wxParse,所以改名字bdParse。
bdParse项目下载地址:https://gitee.com/sootou/bdparse
项目介绍
百度小程序富文本解析工具bdParse,改造自wxparse,支持html转换成百度小程序富文本节点。
安装教程
- 下载整个全部文件,放到你的小程序根目录下
- 在小程序页面的js种直接引入代码:
var bdParse = require('../../bdParse/bdParse.js'); 对应css中引入@import "../../bdParse/bdParse.css"; - 在需要的字段使用baparse,代码:(注意:article和content不要重复)
that.setData({ content:bdParse.bdParse('article', 'html', content, that, 5), }) - swan页面引入模板,
<import src="../../bdParse/bdParse.swan" />然后在需要显示富文本的地方调用:<template is="bdParse" data="{ { {bdParseData:article.nodes} }}" />(注意:data调用改为和wxParse一致写法,注意是三个大括号,原先的直接写{ {article}}不再支持,请注意修改)
使用说明
- swan调用模板的data="{ { {bdParseData:article.nodes} }}"和setData中的article保持一致。
- 调用bdparse组件的时候,组件已经把富文本内容赋值(即setData)给了article;{ { {bdParseData:article.nodes} }} 这种写法的意思是:把article.nodes的内容赋值给bdParseData,bdParse.swan中调用的是bdParseData。
其他说明
- bdParse是在wxParse的基础上改造的,只是把wxParse替换换成了bdParse,包含js,swan, css
- wxml修改后缀改成swan,并且修改了全部模板传值的调用方式,符合百度小程序的使用。
- 修复了其他百度小程序的专有组件,比如s-for,s-if,s-elif,s-for-index等等
- 修复其他问题,比如去掉
<template name="wxParseImg">重复的mode,给所有的s-for-index添加idx(好像不能为空)。 - 其他修改,不再赘述
- 因为直接批量替换内容,基本文章可以满足使用,其他没有做过多测试,欢迎大家反馈bug
参与贡献
- 开发者:腾石建站
- 官网:http://www.tengcee.com
- bdParse.swan改造自wxParse.wxml
- wxParse的原作者github地址: https://github.com/icindy/wxParse
码农不易,多多支持
如果你觉得bdParse帮你解决了问题,请不要忘了打赏,你的支持是我们最大的动力。

边栏推荐
- ImportError: ERROR: recursion is detected during loading of “cv2“ binary extensions. Check OpenCV in
- Segmentation of structured light images using segmentation network
- Realizing sequence annotation with transformers
- Leetcode: array fast and slow pointer method
- 【Unity Mirror】NetworkTeam的使用
- How to realize wireless Ethernet high-speed communication for multiple Mitsubishi PLCs?
- Bezier curve learning
- Pytorch build progression
- Efficiency thesis Reading 1
- KNN resolution
猜你喜欢

What are the conditions for Mitsubishi PLC to realize Ethernet wireless communication?

WBC learning notes (I): manually push WBC formula

How to realize wireless Ethernet high-speed communication for multiple Mitsubishi PLCs?

Install Anaconda + NVIDIA graphics card driver + pytorch under win10_ gpu

Slider verification - personal test (JD)

关于极客时间 | MySQL实战45讲的部分总结

Uniapp uses uparse to parse the content of the background rich text editor and modify the uparse style

爬虫 对 Get/Post 请求时遇到编码问题的解决方案

Nebula diagram_ Object detection and measurement_ nanyangjx

Data warehouse (1) what is data warehouse and what are the characteristics of data warehouse
随机推荐
[unity mirror] use of networkteam
Summary of mobile terminal lightweight model data
Install Anaconda + NVIDIA graphics card driver + pytorch under win10_ gpu
直播回顾 | smardaten李鸿飞解读中国低/无代码行业研究报告:风向变了
WBC learning notes (I): manually push WBC formula
Relationship extraction --r-bert
Software engineering - personal assignment - question review and personal summary
Optimize quiver function in MATLAB to draw arrow diagram or vector diagram (1) -matlab development
20220623 getting started with Adobe Illustrator
Matlab drawing checkerboard (camera calibration)
1.25 suggestions and design of machine learning
Opencv learning notes II
Reverse crawling verification code identification login (OCR character recognition)
Yolov5进阶之一摄像头实时采集识别
Backward usage
Leetcode: array fast and slow pointer method
Exploration of webots and ROS joint simulation (I): software installation
Structure diagram of target detection network
ROS learning notes (6) -- function package encapsulated into Library and called
Degree of freedom analysis_ nanyangjx