vue-v-bind绑定属性到元素
// HTML通过v-bind给div绑定颜色
这里是测试的内容
//通过v-bind给div绑定样式,指向JS中 data下的my_class ,也就是给改div指定了main的样式
这里是测试的内容
//JS 定义myclass对应为main
>
export default {
name: 'demo',
data () {
return {
rand_color: 'blue',
myclass: 'main'
}
},
methods:{
changeColor: function () {
let color= Math.ceil(Math.random() * (999999 - 100000) ) + 100000;
// eslint-disable-next-line
this.rand_color = '#' +color
console.log(color)
}
}
}
//CSS
>
.main{
color: red;
}
推荐阅读
- 第6.2章(设置属性)
- 7、前端--jQuery简介、基本选择器、基本筛选器、属性选择器、表单选择器、筛选器方法、节点操作、绑定事件
- 缓存有关的配置和属性
- 事件解绑与解绑的兼容代码
- 狗趣
- Spring源码解析_属性赋值
- HTML5新增选择器属性方法
- Arcgis根据经纬度批量提取属性值
- SpringBoot|SpringBoot 属性配置中获取值的方式
- 移动端事件绑定