vue中class和style的用法:
来源:互联网 发布:上海峰途网络 编辑:程序博客网 时间:2024/06/13 13:44
class和style的用法:
:class="" v-bind:class=""
:style="" v-bind:style=""
1.:class="[red]" red是数据
:class="[red,b,c,d]"
<style>
.red{
color: red;
}
.blue{
background: blue;
}
</style>
<scriptsrc="vue.js"></script>
<script>
window.onload=function(){
new Vue({
el:'#box',
data:{
red:'red',
b:'blue'
},
methods:{
}
});
};
</script>
</head>
<body>
<divid="box">
<strong:class="[red,b]">文字...</strong>
</div>
</body>
2.json
:class="{red:a, blue:false}"
1.<divid="box">
<strong:class="{red:true,blue:true}">文字...</strong>
</div>
2.<script>
window.onload=function(){
new Vue({
el:'#box',
data:{
a:true,
b:true
},
methods:{
}
});
};
</script>
</head>
<body>
<divid="box">
<strong:class="{red:a,blue:b}">文字...</strong>
</div>
</body>
3.json
:class="json"
data:{
json:{red:a, blue:false}
}
<script>
window.onload=function(){
new Vue({
el:'#box',
data:{
json:{
red:true,
blue:true
}
},
methods:{
}
});
};
</script>
</head>
<body>
<divid="box">
<strong:class="json">文字...</strong>
</div>
</body>
--------------------------
style:
:style="[c]"
:style="[c,d]"
注意: 复合样式,采用驼峰命名法
:style="json"
1.<divid="box">
<strong:style="{color:'red'}">文字...</strong>
</div>
2.<style>
.red{
color: red;
}
.blue{
background: blue;
}
</style>
<scriptsrc="vue.js"></script>
<script>
window.onload=function(){
new Vue({
el:'#box',
data:{
c:{color:'red'}
},
methods:{
}
});
};
</script>
</head>
<body>
<divid="box">
<strong:style="[c]">文字...</strong>
</div>
</body>
3.<style>
.red{
color: red;
}
.blue{
background: blue;
}
</style>
<scriptsrc="vue.js"></script>
<script>
window.onload=function(){
new Vue({
el:'#box',
data:{
c:{color:'red'},
b:{backgroundColor:'blue'}
},
methods:{
}
});
};
</script>
</head>
<body>
<divid="box">
<strong:style="[c,b]">文字...</strong>
</div>
</body>
4.<style>
.red{
color: red;
}
.blue{
background: blue;
}
</style>
<scriptsrc="vue.js"></script>
<script>
window.onload=function(){
new Vue({
el:'#box',
data:{
a:{
color:'red',
backgroundColor:'gray'
}
},
methods:{
}
});
};
</script>
</head>
<body>
<divid="box">
<strong:style="a">文字...</strong>
</div>
</body>
- vue中class和style的用法:
- vue中style与class的绑定
- Vue的class和Style绑定
- vue中的class和style
- Vue中Class与Style绑定
- Vue之style的用法
- vue笔记----class和style绑定
- Vue基础之Class和Style绑定
- Vue——Class和Style绑定
- vue的Class 与 Style 绑定
- Vue的Class 与 Style 绑定
- vue样式(style)和属性(class)绑定的几种基本方法
- Vue学习笔记(4)关于class和style绑定
- Vue.js 官方文档摘记 class和style绑定
- vue学习06--v-bind:class和v-bind:style
- Vue实战--v-bind动态绑定Class和style
- css中style和class的加载顺序!
- vue Class与Style绑定
- VUE冒泡及阻止冒泡
- 一条基本的selenium+python用例
- UIScrollView的基本属性
- rxxhlxdfdhrrjxh
- vue属性
- vue中class和style的用法:
- Netty线程模型详解
- UIScrollView的代理方法
- java中数据类型double&float
- 【Java】java的多线程
- 基于贪心策略的活动选择问题
- Android编程——Fragment
- 软件开发浅谈
- vue的数据绑定