2021-08-20 14:43:10
51阅读
<div>
<template v-for="item in 10">
<li :style="setItem(item).attr">{{setItem(item).value}}</li> </template>
</div>
computed:{
setItem(){
return (item) => {
const newItem = {};
newItem.attr = item == 1?'background:violet':
newItem.attr = item == 2?'background:yellowgreen':
newItem.attr = item == 3?'background:blue':
newItem.attr = item == 4?'background:coral':
newItem.attr = item == 5?'background:deepskyblue':'background:gold';
newItem.value = item == 1?'background:violet':
newItem.value = item == 2?'background:yellowgreen':
newItem.value = item == 3?'background:blue':
newItem.value = item == 4?'background:coral':
newItem.value = item == 5?'background:deepskyblue':'background:gold';
return newItem
}
}
}
最后生成于
2024-05-24 22:37:14
热门推荐:
此内容有帮助 ?
0