第一步:设置一个更换颜色的函数returnrows
function returnrows (index) {
if (index % 2 !== 0) {
return 'background-color:'
} else { return 'background-color:#f3f3f0' }
}
根据索引值判断
第二步:使用插槽调用这个函数
<template v-slot:body-cell-列名的name="props">
<q-td :style="returnrows(props.rowIndex)" :props="props" >
{{props.value}}
</q-td>
</template>
第三步:在return里面返回returnrows