Vuejs 2: envoyer un événement à partir d'un composant à un parent

J'ai ce code:

html

<div id="app">
  {{text}}
  <my-component></my-component>
</div>

js

Vue.component('my-component', {
  template: '<button @click="click">Click me</button>',
  methods: {
    click() {
        this.$emit('send', 'bye')
    }
  }
})

new Vue({
  el: "#app",
  data: {
    text: "hello"
  },
  created() {
    this.$on('send', (text) => {
        this.text = text;
    })
  }
})

de travail exemple: https://jsfiddle.net/rjurado/y4yf6nve/

pourquoi événement send ne fonctionne pas?

InformationsquelleAutor drinor | 2017-02-10