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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| <template> <view class="content"> <swiperTabHead :tabBars="tabBars" :tabIndex="tabIndex" @tabtap="tabtap"></swiperTabHead> <swiper class="swiper-content" :style="{height:swiperheight+'rpx'}" :current="tabIndex" @change="swiperChange"> <swiper-item class="itemswiper" :key="index2" v-for="(newItem ,index2) in tabBars"> <view class="viewat"> {{newItem.id}} {{newItem.name}} </view> </swiper-item> </swiper> </view> </template>
<script> import swiperTabHead from "../../components/scrollbar.vue" export default { components: { swiperTabHead }, data() { return { swiperheight: 0, tabIndex: 0, // 选中的 tabBars: [{ name: "关注", id: "guanzhu" }, { name: "推荐", id: "tuijian" }, { name: "体育", id: "tiyu" }, { name: "热点咨询", id: "redian" }, { name: "财经", id: "caijing" }, { name: "娱乐", id: "yule" }, { name: "社会", id: "yule" }, { name: "自然", id: "yule" }, { name: "币圈", id: "yule" }, { name: "国家体育", id: "yule" }, ] } }, onLoad() { var _this = this uni.getSystemInfo({ success(res) { console.log("屏幕高度 HH = " + res.windowHeight) console.log("屏幕高度 HH222 = " + res.windowHeight * 2) _this.swiperheight = res.windowHeight * 2 - 68 } }) }, methods: { //接受子组件传过来的值点击切换导航 tabtap(index) { var _this = this _this.tabIndex = index; }, // 滑动切换导航 swiperChange: function(e) { var _this = this _this.tabIndex = e.detail.current } } } </script>
<style> </style>
|