父组件 <div class="proNew"> <add-host-basic :hostData="hostInfo" @handleNewPro="handleChange()" /> </div> data() { return { hostInfo:'我要传给子组件' }; }, methods:{ //这个方法是我要传递给子组件的 handleChange() { this.isAdd = false; this.getTableList(); }, }
子组件
export default {
props: ["hostData"],//接受父组件传过来的值 this.hostData就可以用
methods:{
handleAddHost(params) {
//子组件调用父组件的方法 false为向父组件传递的参数,在父组件的方法中可以接收到
this.$emit("handleNewPro", false);
}
}
}