父传子prop
子传父emit
父监听子,可以用到hook,监听子组件数据的变化,也可以用vuex
也可以用emit方法此处
父组件
<el-tab-pane name="fourth">
<span slot="label">样车申请单<el-badge :value="VehicleApplyTodoNum" class="item" /></span>
<VehicleApplyTodo ref="VehicleApplyTodo" @hook:updated="getVehicleApplyTodoNum" />
</el-tab-pane>
import VehicleApplyTodo from './component/vehiclemng/TodoEvent'
export default {
name: 'Dashboard',
components: {
VehicleApplyTodo
},
data() {
return {
VehicleApplyTodoNum: null
}
},
method:{
getVehicleApplyTodoNum() {
this.VehicleApplyTodoNum = this.$refs.VehicleApplyTodo.vsapplytotal
}
}
子组件
data(){
vsapplytotal:0
}
created() {
this.getApplys()
},
methods: {
async getApplys() {
const res = await getVSAEvent(this.tbapplylistQuery)
this.vsapplytotal = res.result.total
}
网友评论