子组件调用父组件的方法
在vue中子组件调用父组件的方法可以直接在需要的地方用
this.$parent.pexample();
这种方式去调用就可以的,pexample()就是需要调用的父组件中的方法名称。但是在iview中这样调用有时会有报错。所以最好用$emit()方法去调用。
示例
父组件中定义一个方法名字,这个名字是在子组件中调用时使用,然后值等于父组件中的方法
<resumedutyModal :show.sync="resumedutyInfoVisible" :value="archivesParams" @refresh= "getDutyInfo"></resumedutyModal>
父组件method中
getDutyInfo(title){ console.info(title) }
子组件中调用,第一个参数为方法名,后面参数为方法的参数。
this.$emit('refresh','你好!');