2021-08-20 14:43:10
<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
}
}
}
最后生成于 2023-06-27 21:37:54
热门推荐: