Whatever i use the selected(Tabs component's props) or not, it always operation abnormally.I saw the code, Tabs Component's tabs variable seem only perceive the newly added Tab component, but when delete, tabs is no change. I'm not sure it's my code wrong or not used correctly.
Look forward to your answer.
// tabs component template
<Tabs>
{#each tabs as { label, key }}
<Tab>
{label}
<span class="del-tab" on:click|preventDefault|stopPropagation={() => delMehod(key)}>x</span>
</Tab>
{/each}
<div class="tab-add" on:click={addMethod}>+</div>
</Tabs>
// dynamically remove
function delMehod(key) {
tabs = tabs.filter(v => {
return v.key !== el.detail
})
}
// dynamically add
function addMethod() {
tabs = [...tabs, { label:'xxx', key: 'xxx' }]
}