I'm using the example from https://v2.vuejs.org/v2/guide/events.html#Method-Event-Handlers
I want to hide a message in #content when the button is clicked, but I encountered weird problem: button element disappears when v-on:click contains anything. When I remove "switch" from it, button appears on page.
Also, my second question: Is this the proper way of showing/hiding things using Vuejs?
My code:
<div id="navigation">
<button v-on:click="switch">Switch</button>
</div>
<div id="content">
<p v-if="show">{{ message}}</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
var content = new Vue({
el: '#content',
data: {
message: 'Hello Vue!',
show: true
}
});
var navigation = new Vue({
el: '#navigation',
data: {
},
methods: {
switch: function() {
content.show = !content.show;
}
}
});
</script>