vue使用computed计算属性进行传参

需求,根据传递过来的宽高比,进行宽高的重新计算

 computed:{
    imgWD(o){
      return function(o){
        return {
            width:'370px',
            height:370*(1/o) + 'px'
        }
      }
    }
  }
<div :style="imgWD(item.crown)" class="img-detail">
    <image resize='stretch' class="itemPhoto" :src="imgUrl + item.photoName"></image>
</div>

参考:https://blog.csdn.net/xlelou/article/details/81477391

猜你喜欢

转载自blog.csdn.net/weixin_36185028/article/details/82946420
今日推荐