<div class="website-item" v-for="(v,k) in data" :key="k">
<text :style="{'color':color()}">随机颜色</text>
</div>
methods: {
color()
{
var colorStr = "";
var randomArr = ["0","1","2","3","4","5", "6","7", "8","9","a", "b","c","d","e","f"]; //产生一个六位的字符串
for (var i = 0; i < 6; i++) {
colorStr += randomArr[Math.ceil(Math.random() * (15 - 0) + 0)];
}
return "#" + colorStr;
},
}
如果是静态数据 以上方法基本上没什么大问题,但是 data的数据会加载第二页,当data发生变化时,之前获取的颜色页会随之变动。
我想要的效果是加载更多出来的列表随机给上颜色,并且加载过的不会变。。。如何避免之前加载过的颜色重新更新???
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…