Vue.component('tabs', { template: `
`, created() { this.tabs = this.$children; }, data() { return { tabs: [], }; }, methods: { selectTab(selectedTab) { this.tabs.forEach(tab => { tab.isActive = (tab.name === selectedTab.name); }); } }, }); Vue.component('tab', { computed: { href() { return '#' + this.name.toLowerCase().replace(/ /g, '-'); } }, data() { return { isActive: false }; }, mounted() { this.isActive = this.selected; }, props: { name: { required: true }, selected: { default: false }, }, template: `