<div class="num1" v-bind:style="'color:' + num1Color" >
市场占有率{{ num1 }}%
</div>
在computed 函数块中添加自定义函数,当内部变量num1变动时,自动变动颜色值
<script>
export default {
name: 'ListIteam',
props: {
soft: String,
data2: {},
},
data() {
return {
num1: 74,
color1: "#7ccd7d",
// visible: true,
// content: '测试内容',
}
},
// filters: {
// contentFormat(content)
// {
// if(content.length > 56)
// {
// return content.substring(0, 56) + '...';
// }
// else return content;
// }
// },
mounted() {},
created() {},
computed: {
num1Color()
{
if(this.num1 > 80) return "#7ccd7d";
else if(this.num1 > 60) return "#e65a56";
else return "#e22121";
}
},
methods: {
}
}
</script>