uniapp,vue 修改v-html中的样式

最近使用Quill富文本编辑器,发现富文本中的图片太宽导致,在移动端超出屏幕

<view v-html="detail" class="detail-box"></view>

解决办法:

  1. 通过 >>> 穿透修改
<style scoped>
	.detail-box  >>>  img{
		width: 100%;
	}
<style>

2:通过正则来修改

this.detail = this.detail.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ');

猜你喜欢

转载自blog.csdn.net/lwang_IT/article/details/103757350