标签:port -o data app methods name use mit something
parent.vue
<template> <div class="wapper"> <p>child tells me:{{childWord}}</p> <child v-on:child-tell-me-something="listenToMyBoy"></child> </div> </template> <script> import child from ‘../components/child‘ export default { name:‘wapper‘, components:{child}, data(){ return{ childWord:‘‘ } }, methods:{ listenToMyBoy(msg){ this.childWord=msg } } } </script>
child.vue
<template> <div> <div @click="up">点我open mouse! </div> </div> </template> <script> export default{ data(){ return { msg: ‘hello from components a‘ } }, methods: { up() { this.$emit(‘child-tell-me-something‘,this.msg) } } } </script>
标签:port -o data app methods name use mit something
原文地址:http://www.cnblogs.com/queenaq/p/7182362.html