上海网站搜索优化,网站文化制度建设,手机管理wordpress,重庆哪些网站推广公司因为image组件默认是有宽度跟高度的#xff0c;所以这个高度不怎么好写 通过load事件来控制图片的高度 话不多说#xff0c;直接上代码#xff0c;
image classimg src/static/image.png :style{ height: imgHeight px }mode所以这个高度不怎么好写 通过load事件来控制图片的高度 话不多说直接上代码
image classimg src/static/image.png :style{ height: imgHeight px }modewidthFix loadonImgLoad
/image
data() {return {imgHeight: 0}
},
methods: {onImgLoad(e) {// 当图片加载完成后获取图片的原始宽度和高度并根据宽度计算出高度const { width, height } e.mp.detail;this.imgHeight (height / width) * 100; // 高度 原始高度 / 原始宽度 * 100},
},
.img{width: 100%;
}
随手一记~