- 场景
- 父组件通过
v-model:show
显示出子组件,立马就调用子组件方法,报找不到那个方法。如下:exchangeListRef 为子组件的ref,initData为子组件方法
- 父组件通过
let exchangePopup = ref(false)
const showExchangePopup = ()=> {
exchangePopup.value = true
exchangeListRef.value.initData()
}
- 解决方法
let exchangePopup = ref(false)
const showExchangePopup = ()=> {
exchangePopup.value = true
nextTick(()=> {
exchangeListRef.value.initData()
})
}