[Vuejs]-Event and Data Handling Vue.js

0👍

You haven’t made use of the attribute ‘menuClick’

const vm = new Vue({
    el: '#root',
    data: () => {
        return {menuClick: false} // changes added
    },
    methods: {
      methodClick(e){
          console.log(event.target.value);
          this.menuClick = !this.menuClick; // changes added

      }  
    },
    template: `
      <div @click="methodClick">
        <a class='dropdown-button btn' href='#' v-if="!menuClick">Open</a> // changes added
        <ul class='dropdown-content' v-else> // changes added
          <li><a href="#!">one</a></li>
          <li><a href="#!">two</a></li>
          <li class="divider"></li>
          <li><a href="#!">three</a></li>
        </ul>
      </div>
    `
});

Leave a comment