欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

tdesign和vue的子組件關閉是父組件執(zhí)行方法

 更新時間:2006年06月30日 00:00:00   作者:xiansibao  
這篇文章主要介紹了tdesign和vue的子組件關閉是父組件執(zhí)行方法,需要的朋友可以參考下

在 <test-test> 組件中,定義一個事件來通知父組件關閉當前組件(或者是執(zhí)行完某個方法例如add或edit方法finally里面 this.$emit('close');通知父組件的close方法)

<template>
  <t-button @click="closeComponent">關閉組件</t-button>
</template>
<script>
export default {
  methods: {
    closeComponent() {
      this.$emit('close');
    }
  }
}
</script>

在父組件中監(jiān)聽 <test-test> 組件觸發(fā)的 close 事件

<template>
<div>
<test-test @close="doTest" />//子組件通知后執(zhí)行的方法
</div>
</template>
<script>
import TestTest from './TestTest.vue';
export default {
        methods: {
                doTest(){
                        alert("請編寫需要執(zhí)行的代碼")
                }
        }
}
</script>

相關文章

最新評論