$root.$emit on Q-menu not possible



  • Hi all,

    I’m use Global Event Bus:

    <template>
      <q-layout view="hHh LpR fFf">
                  <q-menu v-if="menu.id===item.id" v-model="menu.visible">
                    <keep-alive>
                      <component v-if="menu.id" :is="menu.com"/>
                    </keep-alive>
                  </q-menu>
      </q-layout>
    </template>
    <script>
      created: function () {
        this.$root.$on('play', this.play)
      },
      beforeDestroy: function () {
        this.$root.$off('play', this.play)
      }
    </script>
    

    i emit event in q-menu but event not possible

    <template>
      <q-list class="q-trading-layout non-selectable">
        <q-item v-for="(item, index) in xyz" :key="index" @click.prevent="play('click')" clickable v-ripple>
          <q-item-section avatar>
            <q-icon :name="`img:${item.icon}`" />
          </q-item-section>
          <q-item-section>{{item.label}}</q-item-section>
        </q-item>
      </q-list>
    </template>
    <script>
    
    export default {
      name: ''
      methods: {
        play (param) {
          console.log('test')
         this.$root.$emit('play', param)
        }
      }
    }
    </script>
    

    Can you check my problem? Thankyou!





  • @lucasfernog thanks


Log in to reply