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>