父向子传值
父组件
<v-footer :projectdat="dat"></v-footer>
export default { data() { return { dat: 'hahah', } } }
子组件:
export default { data() { return { code: localStorage.getItem('orgcode'), id: this.$route.params.id, } }, props: ['projectdat'] }
子向父传值
父组件这么写
<component-a v-on:child-say="listenToMyBoy"></component-a> <p>Do you like me? {{childWords}}</p> methods: { listenToMyBoy: function (somedata){ this.childWords = somedata } }
子组件component-a这么写
<button v-on:click="onClickMe">like!</button> methods: { onClickMe: function(){ this.$emit('child-say',this.somedata); }