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