scss 中 height 动态赋值

style中:

<style lang="scss" scoped>
.percentage-battery-capacity {
    
    
  display: inline-block;
  position: absolute;
  bottom: 6px;
  left: 12px;
  width: 40%;
  height: var(--heightLine); //关键
  border-radius: 2px;
}
</style>

template中:

<span
    style="{
    
     //关键
    '--heightLine':
    (data.percentageBatteryCapacity[temp] / 100) * 28 + 'px',
   }"
   style="background-color: #bb1717"
   class="percentage-battery-capacity"
></span>

猜你喜欢

转载自blog.csdn.net/weixin_45288172/article/details/130345210