父组件,子组件之间的传值

子组件使用父组件数据:

父组件(:XX=”XX”

子组件:

Pros:{

XX:{

Type:String,

Required:true

}

}

父组件引用子组件:

Import

定义

<子组件标签>

注:子组件像父组件传值需要进行数据复制,不能出现跟父组件同名的情况

Eg:

Import cloneDeep from “lodash/cloneDeep”;

Export default{

Name:”当前vue” //必须起个名

在给子组件传值用

}

方法:{

Let cloneOptions = cloneDeep(this.)//数据复制

使用:this.$emit(‘update:option’,cloneOptions)

...不全

}

监测数据变化值

watch:{
visible(newVul,oldVue){
console.log(newVul);
if (newVul === false){
this.$emit('operationend');
}
}
}

posted on 2020-09-15 13:29  年夜饭  阅读(148)  评论(0编辑  收藏  举报

导航