
"shop-bug" v-for="(item,index) in formData" :key="item">
"shop-img" :src="item.dynamicAddress">
<p class="dynamicText">{{item.dynamicText}}
.shop-bug {
position: relative;
}
.shop-img {
width: 90%;
height: 200px;
border-radius: 20px;
background-color: #2cb6fe;
margin-left: 5%;
margin-top: 20px
}
.dynamicText {
position: absolute;
bottom: 10px;
color: #fff;
left: 7%;
z-index: 10
}
.shop-img {
width: 90%;
height: 200px;
border-radius: 20px;
background-color: #2cb6fe;
margin-left: 5%;
margin-top: 20px;
object-fit: cover; /* 添加 object-fit 属性 */
}
根据需要调整object-fit的值,例如contain可以使图像完全适应容器框,不会被裁剪或拉伸。
首先 加上 mode="widthFix" 如:
<image src="" mode="widthFix"></image>
然后
把.shop-img css中的高度删除,高度就可以自适应了