记录
https://www.cnblogs.com/mycognos/p/9398360.html
<div id="app"> <ul> <!--利用v-for中的index值,绑定样式来实现隔行变色效果--> <li v-for="(name,index) in names" :class="{on:index%2==0,off:index%2!=0}">{{name}}</li> </ul> </div> <script> var vm = new Vue({ el: "#app", data: { names: ['000', '111', '222', '333', '444', '555'] } });
</script>
<style>
.on { background: red; border: 1px solid blue; } .off { background: yellow; border: 1px solid black; }
</style>