diff --git a/src/components/TabComponent.vue b/src/components/TabComponent.vue index b422fc17..74d08f74 100644 --- a/src/components/TabComponent.vue +++ b/src/components/TabComponent.vue @@ -5,18 +5,26 @@ import AppBox from './app/AppBox.vue'; const tab = ref(''); -const index = ref(0); const tabList = ref<{ name: string; label: string }[]>([]); function test() { - index.value++; tabList.value.push({ - name: `สาขาที่ ${index.value}`, - label: `สาขาที่ ${index.value}`, + name: `สาขาที่ ${tabList.value.length + 1}`, + label: `สาขาที่ ${tabList.value.length + 1}`, }); tab.value = tabList.value[tabList.value.length - 1].name; } + +async function close(index: number) { + if (tabList.value.length > 1) { + tabList.value.splice(index, 1); + } + // tab.value = await tabList.value[tabList.value.length - 1].name; + setTimeout(() => { + tab.value = `สาขาที่ ${tabList.value.length.toString()}`; + }, 10); +} - +