No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    $root.$emit on Q-menu not possible

    Help
    2
    3
    261
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      anhln8x last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • lucasfernog
        lucasfernog last edited by

        Hello,

        I believe this is the problem: https://quasar.dev/options/global-event-bus#Usage-with-QDialog-and-QMenu

        A 1 Reply Last reply Reply Quote 0
        • A
          anhln8x @lucasfernog last edited by

          @lucasfernog thanks

          1 Reply Last reply Reply Quote 0
          • First post
            Last post