下一章 上一章 目录 设置
3、第 3 章 vue随机 ...
-
// 创建随机生成颜色的函数
makeColor() {
let arr = [0,1,2,3,4,5,6, 7, 8, 9, \'a\', \'b\', \'c\', \'d\', \'e\', \'f\'];
let color = \"#\";
for (let i = 0; i < 3; i++) {
color += arr[Math.floor(Math.random() * 10)];
}
return color;
},
// 使用随机生成的颜色
use(){
this.color = this.makeColor()
},