官网:
image | uni-app官网https://uniapp.dcloud.io/component/image.html#image
思路:可以通过设置mode+监听宽高来实现
代码:
<image
class="image"
v-if="bookimg"
:style="{width:previewWidth + '%'}"
:src="ossBaseUrl + bookimg"
mode="aspectFit"></image>
data:
previewWidth: null, // 预览宽度,默认60%
完整的实例代码:
文章链接: