[Vuejs]-Show/hide + v-on:click for single page aplication vue.js

0๐Ÿ‘

โœ…

new Vue({
  el: '#app',
  data() {
    return {
      page: 'login'
    }
  },
  methods: {
    loginClick() {
      this.page = 'home'
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>

<div id="app">
  <div v-if="page === 'login'">
    <button @click="loginClick">Login</button>
  </div>
  <div v-if="page === 'home'">
    home page
    <a href="" @click.prevent="page = 'chat'">go to chat</a>
  </div>
  <div v-if="page === 'chat'">
    chat page
  </div>
</div>

Leave a comment