uni-app使用v-html输出富文本图片溢出解决
uni-app使用v-html输出富文本图片溢出解决
·
1.使用
<!-- 这是在获取富文本内容 -->
<view class="detail">
<view v-html="resData.content"></view>
</view>
2.问题:图片溢出了
3.解决
uniapp h5中,v-html,img图片中style=width:auto;会显示图片原来的尺寸,会超出屏幕,替换成width:100%,这样就不会超出屏幕
pageDetaile(data).then(res =>{
this.resData = res.data.data;
this.resData.content = res.data.data.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ');
});
更多推荐
已为社区贡献10条内容
所有评论(0)