<div class="tile-content">
<Progress progressValue="{{item.disk}}" />
</div>
### Progress.vue
script setup
defineProps({
progressValue: String
})
const getProgressColor = (v) => {
console.log(v)
return (parseInt(v) >= 80 ? 'bg-red-500' : 'bg-blue-500');
}
/script
<template>
<div class="progress">
<div class="progress-bar" :class="getProgressColor(progressValue)" :style="{width: progressValue + '%'}"></div>
</div>
</template>
1
TomatoYuyuko 2022-01-19 18:41:20 +08:00
?你为什么不直接 item.disk
|
2
fangwenxue OP @TomatoYuyuko
<Progress progressValue="item.disk" /> 这样报错 |
3
Danswerme 2022-01-19 20:08:46 +08:00 1
<Progress :progressValue="item.disk" />
|
4
dengshen 2022-01-19 20:26:01 +08:00 via iPhone
这是 react 写多了吧?至少看一下 vue 数据绑定部分的文档啊
|
5
TomatoYuyuko 2022-01-20 10:11:58 +08:00
@fangwenxue 动态绑定啊。。不加冒号就是静态的值
|