当前位置:网站首页>小程序editor富文本编辑使用及rich-text解析富文本
小程序editor富文本编辑使用及rich-text解析富文本
2022-07-28 21:54:00 【酱酱的头发还在。】
目录
一、下载
先下载editor的组件
下载地址:https://github.com/jxh1997/Editor
将下载好后的文件放到项目中
二、引入
在需要的用到富文本的组件的json文件中引入:
"usingComponents": {
"richText":"../../components/editor/editor" // 富文本文件的路径
},三、组件的使用
<richText
id='richText'
readOnly='{
{readOnly}}' // 编辑器是否只读
placeholder='{
{placeholder}}'
formatDate='YY/MM/DD'
buttonTxt='保存'
bind:clearBeforeEvent='clearBeforeEvent' //清空编辑器内容之前的回调
bind:clearSuccess='clearSuccess' //清空编辑器内容成功的回调
bind:undo='undo' //撤回内容成功的回调
bind:restore='restore' //恢复内容成功的回调
bind:onEditorReady='onEditorReady' //编辑器初始化完成的时候回调,可以获取组件实例
bind:bindfocus='bindfocus' //编辑器聚焦时触发
bind:bindblur='bindblur' //失去焦点的时候触发
bind:bindinput='bindinput' //编辑器输入中时触发实时返回富文本的内容
bind:insertImageEvent='insertImageEvent' // 插入图片按钮点击时回调
bind:getEditorContent='getEditorContent' //保存按钮点击时回调,返回富文本内容
>
</richText>四、解析富文本
因为我们要展示的是html文件,因此我们需要利用组件来进行解析再展示:
<rich-text nodes="{
{html}}" ></rich-text> this.setData({
html: res.data[0].html.replace('<img ', '<img style="max-width:100%;height:auto;"'),
})其中,后面追加的replace('<img ', '<img style="max-width:100%;height:auto;"'),是为了适配html文件中的图片。因为在富文本中添加的图片,默认会很大。这样设置的话,图片就可以适配。
边栏推荐
- trivy【2】工具漏洞扫描
- In order for digital retail to continue to play its role, we need to give new connotation and significance to digital retail
- Ape anthropology topic 20
- Samba service setup
- Function function
- The computer doesn't know what to uninstall, can't open the calculator, can't edit screenshots, can't open txt files, and so on
- What's special about this wireless router, which is popular in the whole network?
- 【自】-刷题-峰值
- 电脑不知卸载什么,打不开计算器无法编辑截图功能打不开txt文件等等解决方案之一
- 【自】-刷题-动态规划
猜你喜欢

Codeforces Round #810 (Div. 2) A - C

2022焊工(初级)上岗证题目及答案

How to add the index of a set in mongodb to another set in mongodb

xss.haozi.me靶场详解

Xss.haozi.me range details

2022 R2 mobile pressure vessel filling test question simulation test platform operation

2022年R2移动式压力容器充装考题模拟考试平台操作

集火全屋智能“后装市场”,真正玩得转的没几个

解决线程安全问题&&单例模式

Optimization and implementation of custom MVC
随机推荐
Array array object
Asynchronism and synchronization of visa write and read functions by LabVIEW
Learn browser decoding from XSS payload
编译原理研究性学习专题 2——递归下降语法分析设计原理与实现
2022 welder (Junior) work license questions and answers
Object object
Trivy [2] tool vulnerability scanning
【自】-刷题-逻辑
Wechat applet development ③
深度剖析集成学习GBDT
(22) two permutation (DP), package delivery (greedy)
What if win11 cannot find the DNS address? Win11 can't find DNS and can't access the web page solution
浪潮ClusterEngineV4.0 远程命令执行漏洞 CVE-2020-21224
MySQL functions
金仓数据库 KingbaseES 与 Oracle 的兼容性说明(3. 常用函数)
CV语义分割模型小抄(2)
Pagoda phpMyAdmin unauthorized access vulnerability
2022T电梯修理考试试题及模拟考试
Development of small programs ②
Trivy [3] custom scanning strategy