我是 vuejs 的新手,我想显示来自兄弟组件的选项卡数据,下面是我的代码。请帮忙!!
我可以切换选项卡但无法显示来自同级组件的数据
`
<template>
<div>
<section>
<div>logo</div>
<tabs></tabs>
<div>right menu</div>
</section>
<tabs-data></tabs-data>
</div>
</template>
<script>
export default {
components: {
'tabs': {
template: '<div><a href="#" v-on:click="checkClass()" v-bind:class="{ active: ist1 }">tab1</a><a href="#" v-on:click="checkClass()" v-bind:class="{ active: ist2 }">tab2</a></div>',
data () {
return {
ist1: true,
ist2: false
}
},
methods: {
checkClass: function () {
this.ist1 = !this.ist1
this.ist2 = !this.ist2
}
}
},
'tabs-data': {
template: '<section><p v-if="ist1">Tab Data 1</p><p v-else>Tab Data 2</p></section>'
}
}
}
</script>
`