vue 2.0 动态生成字体颜色
html;<spanclass="code":style="{'color':codeColor}"@click="createCode(4)">{{from.checkCode}}</span>data:data() ...
·
html;
<span
class="code"
:style="{'color':codeColor}"
@click="createCode(4)"
>{{from.checkCode}}</span>
data:
data() {
return {
codeColor: ""
};
},
randomColor() {
let R = Math.floor(Math.random() * 255);
let G = Math.floor(Math.random() * 255);
let B = Math.floor(Math.random() * 255);
console.log("rgb(" + R + "," + G + "," + B + ")");
this.codeColor = "rgb(" + R + "," + G + "," + B + ")";
}
更多推荐
已为社区贡献39条内容
所有评论(0)