当前位置:网站首页>A method to solve the self-adaptive width and height of the internal picture of rich text label in wechat applet
A method to solve the self-adaptive width and height of the internal picture of rich text label in wechat applet
2022-06-24 10:24:00 【Wandering in memory of Yu Fei】
Solve the problem of wechat applet rich-text The width and height adaptive method for the internal picture of rich text label
rich-text Rich text labels
rich-text It is the rich text tag of wechat applet , In the use of rich-text When , need rich-text Adaptive width and height of internal picture , What to do at this time ? Let's take a look at the case first :
<view class="contentLine">
<rich-text nodes="{
{content}}"></rich-text>
</view>
programme
There's a rich-text Rich text in wxml Examples of use in , At this time, we need to set it content Parameters ,content Is a rich text content , stay js This can be set in :
onLoad: function (options) {
var mycontent = "<img src='https://www.tpyyes.com/cat.jpg'/>";
mycontent = mycontent.replace(/\<img/gi, '<img style="width:100%;height:auto"');
this.setData({
content: mycontent
});
}
explain
It's on it rich-text How to set rich text content , If the content has not been replace If you replace , The picture will be out of screen , Want to achieve rich-text Internal picture adaptation , You need to put the label style Add to properties “width:100%;height:auto” ( Width 100%, Highly adaptive , That is, the original scale of the picture will be maintained ).
边栏推荐
- Resolved: methods with the same name as their class will not be constructors in
- Troubleshooting steps for Oracle pool connection request timeout
- 形状变化loader加载jsjs特效代码
- SQL sever基本数据类型详解
- 抓包工具charles实践分享
- 学习使用phpstripslashe函数去除反斜杠
- leetCode-929: 独特的电子邮件地址
- 牛客-TOP101-BM29
- numpy.logical_and()
- Uniapp implements the function of clicking to make a call
猜你喜欢
随机推荐
dedecms模板文件讲解以及首页标签替换
Appium自动化测试基础 — 移动端测试环境搭建(一)
3. addition, deletion, modification and query of employees
2. login and exit function development
5. dish management business development
Internet of things? Come and see Arduino on the cloud
Troubleshooting steps for Oracle pool connection request timeout
记录一下MySql update会锁定哪些范围的数据
2022年能源与环境工程国际研讨会(CoEEE 2022)
植物生长h5动画js特效
6. package management business development
学习使用php实现无限极评论和无限极转二级评论解决方案
图解杂项【防止丢失进行存档用的】
Development of anti fleeing marketing software for health products
numpy.logical_or
Leetcode interview question 16.06: minimum difference
如何在一个页面上使用多个KindEditor编辑器并将值传递到服务器端
Uniapp implementation forbids video drag fast forward
涂鸦智能携多款重磅智能照明解决方案,亮相2022美国国际照明展
Six states of threads








