admin管理员组

文章数量:1356761

<mt-tabs
    @new-item-active="setActiveItem"
    :items="[
        {
            label: '1',
            name: 'tab1'
        },
        {
            label: '2',
            name: 'tab2'
        }
    ]"
>
    <template #content>
        <p>Tab Content Loaded!</p>
    </template>
</mt-tabs>

1 and 2 are showing up but the content is not visible. Any ideas what I am doing wrong? I changed template #content to template #default with no success.

<mt-tabs
    @new-item-active="setActiveItem"
    :items="[
        {
            label: '1',
            name: 'tab1'
        },
        {
            label: '2',
            name: 'tab2'
        }
    ]"
>
    <template #content>
        <p>Tab Content Loaded!</p>
    </template>
</mt-tabs>

1 and 2 are showing up but the content is not visible. Any ideas what I am doing wrong? I changed template #content to template #default with no success.

Share Improve this question edited Mar 31 at 8:38 sh0pware_n00b asked Mar 30 at 21:04 sh0pware_n00bsh0pware_n00b 214 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The content slot <template #content> is not supported anymore. You need to set the content manually outside the component <mt-tabs>.

You can use the @new-item-active event to get the active item and set it to a variable. Then, use variables in your template:

<template>
  <div>
    <mt-tabs
      :items="[
        { label: '1', name: 'tab1' },
        { label: '2', name: 'tab2' }
      ]"
      @new-item-active="setActiveItem"
    />
    
    <sw-tab1 v-if="currentActiveTab === 'tab1'" />
    <sw-tab2 v-if="currentActiveTab === 'tab2'" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentActiveTab: 'tab1',
    };
  },
  methods: {
    setActiveItem(item: string): void {
      this.currentActiveTab = item;
    },
  },
};
</script>

本文标签: shopwareTab content not showing after updating swtabs with mttabsStack Overflow