如何通过Vue的v-for实现动态修改循环元素的class样式?
- 内容介绍
- 文章标签
- 相关推荐
本文共计332个文字,预计阅读时间需要2分钟。
在v-bind:class上绑定索引函数,使用div和v-for遍历shoplist,并设置样式为最大宽度20rem,绑定class为calculate(index)。计算函数必须添加index参数。data函数返回对象包含colorList数组:['primary', 'danger', 'secondary', 'info']。
本文共计332个文字,预计阅读时间需要2分钟。
在v-bind:class上绑定索引函数,使用div和v-for遍历shoplist,并设置样式为最大宽度20rem,绑定class为calculate(index)。计算函数必须添加index参数。data函数返回对象包含colorList数组:['primary', 'danger', 'secondary', 'info']。

