当前位置:网站首页>小程序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文件中的图片。因为在富文本中添加的图片,默认会很大。这样设置的话,图片就可以适配。
边栏推荐
- [self] - question brushing - dynamic programming
- 酒店预订系统数据库房间库存设计思路
- 二舅火了,全网刷屏,他凭什么能治好我的精神内耗?
- Rhce第一天
- Few people can really play in the "aftermarket" of the whole house intelligent fire collection
- 深度剖析集成学习GBDT
- 互动滑轨屏在展厅中应用的制作步骤
- 经典的拓扑排序问题——LeetCode207 课程表+LeetCode210 课程表II
- 金仓数据库KingbaseES客户端编程接口指南-ODBC(5. 开发过程)
- 英特尔数据中心GPU正式发货,以开放灵活提供强劲算力
猜你喜欢

KingbaseES客户端编程接口指南-ODBC(4. 创建数据源)

宝塔 phpmyadmin未授权访问漏洞

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

使用这个,你发的消息就无法被监控了

深开鸿:万物智联的大江上,升起一轮开源鸿蒙月

What's special about this wireless router, which is popular in the whole network?

xss.haozi.me靶场详解
![[self] - brush questions array](/img/a9/d12c41183df6961b2e9dd7cb49dfec.png)
[self] - brush questions array

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

Why did "you" become a test / development programmer? The value of your existence
随机推荐
[self] - brush questions BFS
My second uncle is angry and swipes the screen all over the network. How can he cure my spiritual internal friction?
Wechat applet development ③
MySQL transaction and storage system
22牛客多校day1 I - Chiitoitsu 概论dp
Trivy [2] tool vulnerability scanning
[self] - brush questions array
LabVIEW对VISA Write和Read函数的异步和同步
Okaleido生态核心权益OKA,尽在聚变Mining模式
通过Wi-Fi 7实现极高吞吐量——洞察下一代Wi-Fi物理层
Why did "you" become a test / development programmer? The value of your existence
金仓数据库KingbaseES 客户端编程接口指南 - ODBC特性支持约束
ACM SIGIR 2022 | 美团技术团队精选论文解读
浪潮ClusterEngineV4.0 远程命令执行漏洞 CVE-2020-21224
General paging - front desk
Samba service setup
经典双栈实现队列,注意遍历栈的判定条件修改。
猿人学第二十题
The front mounted ADAS camera in parking increased by 54.15% year-on-year, with TOP10 suppliers taking the lead
Meet the outbreak period with the integration of transportation and parking, rush for mass production or build a technical moat?