当前位置:网站首页>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 ).
边栏推荐
- 解决Deprecated: Methods with the same name as their class will not be constructors in报错方案
- 分布式 | 如何与 DBLE 进行“秘密通话”
- 5.菜品管理业务开发
- 自定义kindeditor编辑器的工具栏,items即去除不必要的工具栏或者保留部分工具栏
- 线程的 sleep() 方法与 wait() 方法的区别
- The difference between the sleep () method and the wait () method of a thread
- 416 binary tree (first, middle and last order traversal iteration method)
- Cookie encryption 4 RPC method determines cookie encryption
- 23. Opencv——图像拼接项目
- 【Energy Reports期刊发表】2022年能源与环境工程国际会议(CFEEE 2022)
猜你喜欢

Leetcode-2221: triangular sum of arrays

美国电子烟巨头 Juul 遭遇灭顶之灾,所有产品强制下架

上升的气泡canvas破碎动画js特效

Record the range of data that MySQL update will lock

消息队列的作用

分布式系统你必须了解的点-CAP

【资源分享】2022年环境工程与生物技术国际会议(CoEEB 2022)

The difference between the sleep () method and the wait () method of a thread

canvas无限扫描js特效代码

5.菜品管理业务开发
随机推荐
Leetcode interview question 16.06: minimum difference
Uniapp develops wechat official account, and the drop-down box selects the first one in the list by default
大中型企业如何构建自己的监控体系
使用swiper左右轮播切换时,Swiper Animate的动画失效,怎么解决?
百度网盘下载一直请求中问题解决
The difference between static link library and dynamic link library
Juul, the American e-cigarette giant, suffered a disaster, and all products were forced off the shelves
Web site development, lazy image loading
简单的价格表样式代码
上升的气泡canvas破碎动画js特效
numpy. linspace()
Recursive traversal of 414 binary tree
Learn to use the phpstripslush function to remove backslashes
tf.errors
leetCode-498: 對角線遍曆
如何在一个页面上使用多个KindEditor编辑器并将值传递到服务器端
Common methods of thread scheduling
图解杂项【防止丢失进行存档用的】
SSM integration
[db2] sql0805n solution and thinking