s3e34 conditions with if
This commit is contained in:
parent
8d5c1a2edf
commit
c5776f88d5
11
app.js
11
app.js
|
@ -1,15 +1,6 @@
|
||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
color: "gray",
|
show: true
|
||||||
width: 100
|
|
||||||
},
|
|
||||||
computed:{
|
|
||||||
myStyle(){
|
|
||||||
return {
|
|
||||||
backgroundColor: this.color,
|
|
||||||
width: this.width + "px"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
11
index.html
11
index.html
|
@ -7,12 +7,11 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id='app'>
|
<div id='app'>
|
||||||
<div class="demo" :style="{backgroundColor: color}"></div>
|
<button type="button" name="button" @click="show = !show">Switch</button>
|
||||||
<div class="demo" :style="myStyle"></div>
|
|
||||||
<div class="demo" :style="[myStyle, {height: width + 'px'}]"></div>
|
<p v-if="show">You can see me</p>
|
||||||
<hr>
|
<p v-else>Now you see me</p>
|
||||||
<input type="text" v-model="color">
|
<p>Do you also see me?</p>
|
||||||
<input type="text" v-model="width">
|
|
||||||
</div>
|
</div>
|
||||||
<script src="app.js" charset="utf-8"></script>
|
<script src="app.js" charset="utf-8"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user