s2e27 using objects

This commit is contained in:
Tyrel Souza 2018-04-13 14:57:51 -04:00
parent 41c5af3862
commit f97f01c6da
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
2 changed files with 10 additions and 8 deletions

8
app.js
View File

@ -5,4 +5,12 @@ var app = new Vue({
attachGreen: false, attachGreen: false,
attachBlue: true attachBlue: true
}, },
computed:{
divClasses(){
return {
red: this.attachRed,
blue: !this.attachRed
}
}
}
}); });

View File

@ -11,14 +11,8 @@
@click="attachRed = !attachRed" @click="attachRed = !attachRed"
:class="{red: attachRed}" :class="{red: attachRed}"
></div> ></div>
<div class="demo" <div class="demo" :class="divClasses"></div>
@click="attachGreen = !attachGreen" <div class="demo"></div>
:class="{green: attachGreen}"
></div>
<div class="demo"
@click="attachBlue = !attachBlue"
:class="{blue: attachBlue}"
></div>
</div> </div>
<script src="app.js" charset="utf-8"></script> <script src="app.js" charset="utf-8"></script>
</body> </body>