<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>css样式控制</title>
<style type="text/css">
div>div{
width: 60px;
height: 60px;
border: 2px solid #bbbbbb;
text-align: center;
line-height: 60px;
font-size: 30px;
margin: 10px;
float: left;
}
.selected{
border-color: #000000;
}
.active{
background-color: #bbbbbb;
}
</style>
</head>
<body>
<div id="app">
<div>1</div>
<div v-bind:style="[div2,divComputed3]">2</div>
<div v-bind:style="[{borderColor:'#000'},divComputed3]">3</div>
<div v-bind:style="divMethod4()">4</div>
</div>
<script src="../js/vue.js"></script>
<script>
let vm = new Vue({
el:'#app',
data:{
div2:{
'border-color':'#000'
},
div3:{
'background':'#bbb'
},
div4:{
borderColor:'#000',
background: '#bbb'
}
},
computed:{
divComputed2:function () {
return this.div2;
},
divComputed3(){
return this.div3;
}
},
methods:{
divMethod4:function () {
return this.div4;
}
}
});
</script>
</body>
</html>
vue-前端第4章class11.html
最新推荐文章于 2024-08-04 16:33:59 发布