tabBox.vue
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<template>
<div class="tabBox">
<!-- 主内容区域 -->
<van-tabs @change="onChange" swipeable v-model="active">
<van-tab v-for="(item,index) in tabbar" :key="index" :title="item.title">
<div class="tabBox_main">
<div class="tabbar" v-for="(item, index) in tabbaromponents.ads" :key="index">
<!-- 关爱屋 -->
<html-box
v-if="item.style == '14'"
:htmls="item">
</html-box>
<img-list-box
v-if="item.style == '1'"
@detail="toDetail"
:imgLists="item">
</img-list-box>
<column-commodity-list-box
v-if="item.style == '15'"
@detail="toCommodityDetail"
:columnLists="item">
</column-commodity-list-box>
</div>
</div>
</van-tab>
</van-tabs>
</div>
</template>
<script>
import htmlBox from "@/components/htmlBox/htmlBox";
import imgListBox from "@/components/imgListBox/imgListBox";
import columnCommodityListBox from "@/components/columnCommodityListBox/columnCommodityListBox";
import discountZone from "@/components/discountZone/discountZone";
export default {
name: 'name',
data () {
return {
active: 0,
tabbaromponents: null, // 组件库
}
},
props:["tabbar"],
components: {
htmlBox,
imgListBox,
columnCommodityListBox,
discountZone
},
created(){
// 初始化的时选中关爱屋
this.tabbaromponents = this.tabbar.find((item)=>{
return item.title === "关爱屋"
});
console.log(this.tabbaromponents)
},
methods: {
onChange(name, title) {
// 切换tab时判断展示哪个组件
this.tabbaromponents = this.tabbar.find((item)=>{
return item.title === title
});
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less">
@import './tabBox';
</style>