Created
September 8, 2017 05:39
-
-
Save ceme/4642cb24fe935a020a7dbb6ad554b6b6 to your computer and use it in GitHub Desktop.
vuejs : Bind visibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>vuejs : Bind visibility</title> | |
<style> | |
* { margin: 0; padding: 0; box-sizing: border-box; } | |
body { font: 21px Helvetica, Arial; } | |
span::after { | |
content: ''; | |
display: block; | |
clear: both; | |
} | |
</style> | |
<script src="https://unpkg.com/vue/dist/vue.js"></script> | |
</head> | |
<body> | |
<!-- Bind visibility --> | |
<div id="app"> | |
<p v-if="showme">Now you see me</p> | |
<button v-on:click='toggleMessage'>{{buttonMessage}}</button> | |
</div> | |
<script> | |
var app3 = new Vue({ | |
el: '#app', | |
data: { | |
showme: true, | |
buttonMessage: "Hide Message" | |
}, | |
methods: { | |
toggleMessage: function() { | |
this.showme = !this.showme; | |
this.buttonMessage = this.getMessage(); | |
}, | |
getMessage: function() { | |
return this.showme ? "Hide Message" : "Show Message"; | |
} | |
} | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment