当前位置:网站首页>小程序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文件中的图片。因为在富文本中添加的图片,默认会很大。这样设置的话,图片就可以适配。
边栏推荐
- 2022年R2移动式压力容器充装考题模拟考试平台操作
- 通过Wi-Fi 7实现极高吞吐量——洞察下一代Wi-Fi物理层
- 2022 welder (Junior) work license questions and answers
- MySQL log management, backup and recovery
- 英特尔数据中心GPU正式发货,以开放灵活提供强劲算力
- 2022g3 boiler water treatment test simulation 100 questions simulation test platform operation
- Arduino uno driver universe 1.8 'TFT SPI screen example demonstration (including data package)
- 【自】-刷题-BFS
- Rhce第二天
- 事件抽取文献整理(2008-2017)
猜你喜欢

Shenkaihong: on the river of Zhilian of all things, there is a bright moon of open source

Pin mapping relationship of stm32f103c series single chip microcomputer under Arduino framework

trivy【3】自定义扫描策略

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

【自】-刷题-动态规划

Go 中的并发 Concurrency

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

2022 simulated examination platform operation of hoisting machinery command examination questions

2022 G2 power plant boiler stoker examination question bank simulated examination platform operation

My second uncle is angry and swipes the screen all over the network. How can he cure my spiritual internal friction?
随机推荐
【自】-刷题-BFS
Trivy [3] custom scanning strategy
深度剖析集成学习Xgboost
Samba service setup
2022焊工(初级)上岗证题目及答案
JS small method
(22) two permutation (DP), package delivery (greedy)
LabVIEW对VISA Write和Read函数的异步和同步
Function function
Mongodb index add, view, export, delete
ACM SIGIR 2022 | 美团技术团队精选论文解读
二舅火了,全网刷屏,他凭什么能治好我的精神内耗?
Why did "you" become a test / development programmer? The value of your existence
2022T电梯修理考试试题及模拟考试
事件抽取文献整理(2008-2017)
Xss.haozi.me range details
【自】-刷题-逻辑
Compatibility description between kingbasees and Oracle (2. Data type)
CV语义分割模型小抄(2)
金仓数据库 KingbaseES V8.3至V8.6迁移最佳实践(2. KingbaseES V8.3和 V8.6 兼容性)