[Vuejs]-Vue js: set notification count to zero

0👍

Emit an event from sidebar and handle the event in the main app.

main app:

<template>
  <!-- ... -->
  <sidebar :number="count" @reset="onReset" />
  <!-- ... -->
</template>

<script>
export default {
  // ...
  methods: {
    onReset() {
      // api calls, etc.
      this.count = 0;
    }
  }
}
</script>

sidebar:

<template>
  <!-- ... -->
  <button @click="$emit('reset')">Reset notification count</button>
  <!-- ... -->
</template>

Leave a comment