【无标题】

所有的事件本质上是回调,是钩子,也就是有一个事情,有可能会发生,发生了你再来找我,什么时候发生了不知道,但是发生了我给你一个入口

父组件向子组件传递的时候 ,子组件通过prop来接这个组件的参数
有点类似于react的组件参数传递
Vue.component(‘child’, {
template: <div> <h4>来自父亲的Value{{myValue}}</h4> <input type="text" v-model="myValue.d"> </div>,
props: [‘myValue’],
methods: {

        },
        update: function () {
            console.log('子组件的update', this.myValue.d)
        },
        mounted: function () {
            console.log('子组件的mount', this.myValue.d)
        }

    })

    // 父组件
    Vue.component('parent', {
        template: `
         <div>
            <h4>父亲的Value{{parentValue2}}</h4>
            <input type="text" v-model="parentValue2.d">
            <hr/>
            <child :myValue = "parentValue2"></child>
         </div>
        
        `,
        data: function () {
            return {
                parentValue: '乌拉乌拉',
                parentValue2: {
                    d: 'wula'
                }
            }
        },
        update: function () {
            console.log('父组件的update', this.parentValue2.d)
        }
    })
    new Vue({
        el: '#app'
    });
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值