1. 程式人生 > >vue使用computed計算屬性進行傳參

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