我的 vue 應(yīng)用程序中有三個組件:家:(巴頓的祖父母)對話框:(Home 的孩子 / Button 的父母)按鈕:(家的孫子)該Home組件有一個異步方法:async handleDialogAccept() { try { const response = await this.$axios.get('https://jsonplaceholder.typicode.com/todos/'); console.log(response.data); } catch (err) { console.log(err); }},它會在Dialog組件發(fā)出“accept”自定義事件后立即執(zhí)行:<dialog-confirmation @accept="handleDialogAccept()"/>該Dialog組件有一個子組件 ( Button):<button-accept v-on="$listeners"> Accept</button-accept>在 mybuttonAccept.vue中導(dǎo)入Dialog并使用如上所示具有下一個結(jié)構(gòu):<template> <v-btn color="primary" @click="handleClick()" :loading="loading" :disabled="loading" > <slot name="accept"></slot> </v-btn></template><script>export default { props: ['parentFunction'], data() { return { loading: false, }; }, methods: { handleClick() { this.$emit('accept'); }, },};</script>我想在handleClick方法中執(zhí)行以下步驟:設(shè)置loading為真發(fā)出接受自定義事件等到handleDialogAccept完成設(shè)置loading為假有沒有等待這樣做?
等待在孫組件中解析祖父組件的方法
繁星點點滴滴
2021-06-30 04:34:22