<template>
<gracePage :customHeader="false">
<view slot="gBody" class="grace-body">
<view class="grace-margin-top">
<graceNavBar :items="tabs" :currentIndex="currentIndex" @change="navChange"></graceNavBar>
</view>
<swiper class="swiper grace-margin-top" :current="currentIndex" @change="swiperChange">
<swiper-item class="demo" v-for="(item, index) in tabs" :key="index">
<text class="demo-txt">{{item}}</text>
</swiper-item>
</swiper>
</view>
</gracePage>
</template>
<script>
import gracePage from "../../graceUI/components/gracePage.vue";
import graceNavBar from "../../graceUI/components/graceNavBar.vue";
export default {
data() {
return {
currentIndex: 0,
tabs: [ '关注', '推荐', '体育', '热点', '国内', '国外', '其他']
}
},
methods:{
navChange: function (e) {
this.currentIndex = e;
},
swiperChange: function (e) {
var index = e.detail.current;
this.currentIndex = index;
}
},
components:{gracePage, graceNavBar}
}
</script>
<style>
/* 局部选项卡应该固定高度 可以避免选项切换引起的页面抖动 */
.swiper{width:100%; height:388rpx;}
.demo{width:100%; height:388rpx; background-color:#F5F6F8; text-align:center;}
.demo-txt{line-height:388rpx; color:#999999; font-size:50rpx;}
</style>
<template>
<gracePage :customHeader="false">
<view slot="gBody" class="grace-body">
<view class="grace-margin-top">
<graceNavBar :items="tabs" :currentIndex="currentIndex" @change="navChange"></graceNavBar>
</view>
<swiper class="swiper grace-margin-top" :current="currentIndex" @change="swiperChange">
<swiper-item class="demo" v-for="(item, index) in tabs" :key="index">
<text class="demo-txt">{{item}}</text>
</swiper-item>
</swiper>
</view>
</gracePage>
</template>
<script>
import gracePage from "../../graceUI/weexComponents/gracePage.nvue";
import graceNavBar from "../../graceUI/weexComponents/graceNavBar.nvue";
export default {
data() {
return {
currentIndex: 0,
tabs: [ '关注', '推荐', '体育', '热点', '国内', '国外', '其他']
}
},
methods:{
navChange: function (e) {
this.currentIndex = e;
},
swiperChange: function (e) {
var index = e.detail.current;
this.currentIndex = index;
}
},
components:{gracePage, graceNavBar}
}
</script>
<style>
/* 局部选项卡应该固定高度 可以避免选项切换引起的页面抖动 */
.swiper{width:700rpx; height:388rpx;}
.demo{width:700rpx; height:388rpx; background-color:#F5F6F8;}
.demo-txt{line-height:388rpx; color:#999999; font-size:50rpx; text-align:center;}
</style>
.wxml
<gracePage customHeader="{{false}}">
<view slot="gBody" class="grace-body">
<view class="grace-margin-top">
<graceNavBar items="{{tabs}}" currentIndex="{{currentIndex}}" bind:change="navChange"></graceNavBar>
</view>
<swiper class="swiper grace-margin-top" current="{{currentIndex}}" bind:change="swiperChange">
<swiper-item class="demo" wx:for="{{tabs}}" wx:key="index">
<text class="demo-txt">{{item}}</text>
</swiper-item>
</swiper>
</view>
</gracePage>.js
Page({
data:{
currentIndex: 0,
tabs: ['关注', '推荐', '体育', '热点', '国内', '国外', '其他']
},
navChange: function (e) {
this.setData({currentIndex : e.detail});
},
swiperChange: function (e) {
var index = e.detail.current;
this.setData({ currentIndex: index });
}
}).json
{
"usingComponents": {
"gracePage" : "../../graceUI/components/gracePage",
"graceNavBar": "../../graceUI/components/graceNavBar"
}
}.wxss
/* 局部选项卡应该固定高度 可以避免选项切换引起的页面抖动 */
.swiper{width:100%; height:388rpx;}
.demo{height:388rpx; background-color:#F5F6F8; text-align:center;}
.demo-txt{line-height:388rpx; color:#999999; font-size:50rpx;}