vue之父子组件通信

. -子组件间通信

let children={
    template:`<div><h1>{{send}}</h1></div>`,  # 将传过来的信息send渲染出来
    props:['send']  # 通过props来获取父级传过来的信息
};

let parent={
    components:{xx:children},
    template:'<xx v-bind:send="num"></xx>', # 自定义个绑定属相send,data
    data(){return {num:6688}}  # 获取num,传给send属相
};

new Vue({
    el:'#app',
    components:{parent},
    template:'<parent></parent>'
})

猜你喜欢

转载自www.cnblogs.com/quzq/p/10023068.html