现在写微信小程序,遇到了个问题

问题:上边是轮播图,下边是选项卡,都用的swiper组件,上边的轮播图一写上,下边的选 项卡就出问题,出现的效果就是上边的轮播图自动轮播,下边的选项卡也轮播,第二个问题就是选项卡里的内容是显示不全,分析原因是swiper不能自适应高度,请大神关注解决一下

直接代码:

这是JS里边的

//获取应用实例

const app = getApp()

Page({

data: {

// 轮播图

imgUrls: [

'../../images/l1.png',

'../../images/l2.png',

'../../images/l3.png',

'../../images/l4.png',

'../../images/l4.png'

],

swiperIndex: 0,//如果不写第一次运行会出错

// 轮播图

},

// 轮播图

bindchange(e) {

this.setData({

swiperIndex: e.detail.current

})

},

// 轮播图

// 选项卡

data: {

currentData: 0,

},

//获取当前滑块的index(下标) 选项卡

bindchange: function (e) {

const that = this;

that.setData({

currentData: e.detail.current

})

},

// 选项卡

// 点击切换 滑动index赋值 选项卡

checkCurrent: function (e) {

const that = this;

if (that.data.currentData == e.target.dataset.current) {

return false;

} else {

that.setData({

currentData: e.target.dataset.current

})

}

}

// 选项卡 end

})

这是WXML里的

<!-- 中间选项卡 -->

<view class="topTabSwiper">

<view class='tab {{currentData == 0 ? "tabBorer" : ""}}' data-current = "0" bindtap='checkCurrent'>推荐</view>

<view class='tab {{currentData == 1 ? "tabBorer" : ""}}' data-current = "1" bindtap="checkCurrent">热点</view>

<view class='tab {{currentData == 2 ? "tabBorer" : ""}}' data-current = "2" bindtap='checkCurrent'>关注</view>

</view>

<!-- 中间选项卡END -->

 

<!-- 滑动显示的内容 -->

<swiper class="swiper" current="{{currentData}}" style="height:{{con_cent[current]}}rpx;" bindchange="bindchange">

<swiper-item><view class="swiper_con">

<!-- 中间内容页 -->

<view class="con_cent">

<!-- 标题头像发布日期 -->

<view class="conen_title">

<view class="conent_img"><image src="../../../images/1.png"></image></view>

<view class="conent_title">

<view class="content_tt">

<view class="conentt_ming">海尔小集团</view>

<view class="conentt_admin">管理员</view>

</view>

<view class="content_date">前天19:20</view>

</view>

</view>

<!-- 标题头像发布日期END -->

<!-- 线条 -->

<!-- <view class="con_hr">线条</view> -->

<!-- 线条 -->

<!-- 内容版块 -->

<view class="con_conent">

<view class="conentt_ent">

<view class="conentt_title">

<strong class="conett_strong">#今日头条#</strong>

钢材市哈哈 合。

</view>

</view>

</view>

<!-- 内容板块END -->

<view class="con_footer">

<view class="conf_cont">

<view class="confot_zan">

<icon class="confotz_icon" type="waiting" size="15" color="#dddddd"></icon>

<view class="confotz_text">点赞</view>

</view>

<view class="confot_zhuan">

<icon class="confotz_icon" type="success" size="15" color="#dddddd"></icon>

<view class="confotz_text">转发</view>

</view>

</view>

</view>

</view>

<!-- 中间内容页END -->


 

<!-- 中间内容页 -->

<view class="con_cent">

<!-- 标题头像发布日期 -->

<view class="conen_title">

<view class="conent_img"><image src="../../../images/1.png"></image></view>

<view class="conent_title">

<view class="content_tt">

<view class="conentt_ming">海尔小集团</view>

<view class="conentt_admin">管理员</view>

</view>

<view class="content_date">前天19:20</view>

</view>

</view>

<!-- 标题头像发布日期END -->

<!-- 线条 -->

<!-- <view class="con_hr">线条</view> -->

<!-- 线条 -->

<!-- 内容版块 -->

<view class="con_conent">

<view class="conentt_ent">

<view class="conentt_title">

<strong class="conett_strong">#今日头条#</strong>

哈哈哈 合。

</view>

</view>

</view>

<!-- 内容板块END -->

<view class="con_footer">

<view class="conf_cont">

<view class="confot_zan">

<icon class="confotz_icon" type="waiting" size="15" color="#dddddd"></icon>

<view class="confotz_text">点赞</view>

</view>

<view class="confot_zhuan">

<icon class="confotz_icon" type="success" size="15" color="#dddddd"></icon>

<view class="confotz_text">转发</view>

</view>

</view>

</view>

</view>

<!-- 中间内容页END -->

</view></swiper-item>

 

<swiper-item><view class="swiper_con">

<!-- 动态等标题 -->

<view class="con_nav">

<view class="cnav_text">动态</view>

<image class="cnav_img" src="../../../images/images/筛选.png"></image>

</view>

<!-- 动态等标题导航 -->


 

<!-- 中间内容页 -->

<view class="con_cent">

<!-- 标题头像发布日期 -->

<view class="conen_title">

<view class="conent_img"><image src="../../../images/1.png"></image></view>

<view class="conent_title">

<view class="content_tt">

<view class="conentt_ming">海尔小集团</view>

<view class="conentt_admin">管理员</view>

</view>

<view class="content_date">前天19:20</view>

</view>

</view>

<!-- 标题头像发布日期END -->

<!-- 线条 -->

<!-- <view class="con_hr">线条</view> -->

<!-- 线条 -->

<!-- 内容版块 -->

<view class="con_conent">

<view class="conentt_ent">

<view class="conentt_title">

<strong class="conett_strong">#今日头条#</strong>

钢材市场之所以淡季不哈哈哈 。

</view>

</view>

</view>

<!-- 内容板块END -->

<view class="con_footer">

<view class="conf_cont">

<view class="confot_zan">

<icon class="confotz_icon" type="waiting" size="15" color="#dddddd"></icon>

<view class="confotz_text">点赞</view>

</view>

<view class="confot_zhuan">

<icon class="confotz_icon" type="success" size="15" color="#dddddd"></icon>

<view class="confotz_text">转发</view>

</view>

</view>

</view>

</view>

<!-- 中间内容页END -->

</view></swiper-item>


 

<swiper-item><view class="swiper_con">

<!-- 动态等标题 -->

<view class="con_nav">

<view class="cnav_text">动态</view>

<image class="cnav_img" src="../../../images/images/筛选.png"></image>

</view>

<!-- 动态等标题导航 -->

<!-- 中间内容页 -->

<view class="con_cent">

<!-- 标题头像发布日期 -->

<view class="conen_title">

<view class="conent_img"><image src="../../../images/1.png"></image></view>

<view class="conent_title">

<view class="content_tt">

<view class="conentt_ming">海尔小集团</view>

<view class="conentt_admin">管理员</view>

</view>

<view class="content_date">前天19:20</view>

</view>

</view>

<!-- 标题头像发布日期END -->

<!-- 线条 -->

<!-- <view class="con_hr">线条</view> -->

<!-- 线条 -->

<!-- 内容版块 -->

<view class="con_conent">

<view class="conentt_ent">

<view class="conentt_title">

<strong class="conett_strong">#今日头条#</strong>

钢材哈哈哈 合俣。

</view>

</view>

</view>

<!-- 内容板块END -->

<view class="con_footer">

<view class="conf_cont">

<view class="confot_zan">

<icon class="confotz_icon" type="waiting" size="15" color="#dddddd"></icon>

<view class="confotz_text">点赞</view>

</view>

<view class="confot_zhuan">

<icon class="confotz_icon" type="success" size="15" color="#dddddd"></icon>

<view class="confotz_text">转发</view>

</view>

</view>

</view>

</view>

<!-- 中间内容页END -->

</view></swiper-item>

</swiper>

这是WXSS里边的

/* 轮播图部分 */

.boximg{

background:#B70100;

padding:10rpx;

}

 

.swiperClass {

margin: 0;

margin-top: 10px;

}

.slide-image {

width: 670rpx;

height:350rpx;

border-radius: 10px;

position: relative;

}

image.active {

transform: none;

transition: all 0.2s ease-in 0s;

}

image.quiet {

transform: scale(0.8333333);

transition: all 0.2s ease-in 0s;

}

 

/* 轮播图部分END */

/* 热点推荐关注选项卡 */

.tab {

float:left;

width:33.3333%;

text-align: center;

padding:10rpx 0;

}

.topTabSwiper {

border-top: 1px solid #ccc;

border-bottom: 1px solid #ccc;

zoom: 1;

}

.topTabSwiper:after{

content:"";

clear:both;

display:block;

}

.tabBorer{

border-bottom:1rpx solid #f00;

color:#f00;

}

/* 热点推荐关注选项卡END */

/* 内容显示滑动组件 */

.swiper{

width:750rpx;

background:#eaeaea;

}

.swiper_con{

width:750rpx;

}

/* 内容显示滑动组件END */

/* 动态导航 */

.con_nav{

width:630rpx;

height:70rpx;

margin:0 auto;

}

.cnav_text{

float:left;

text-align: center;

line-height:70rpx;

}

.cnav_img{

margin-top:19rpx;

float:right;

width:41rpx;

height:41rpx;

}

/* 动态导航结束 */

 

/* 中间内容部分 */

.con_cent{

width:715rpx;

height:440rpx;

margin:auto auto 20rpx auto;

background:#ffffff;

border-radius: 20rpx;

position:relative;

}

.conen_title{

width:635rpx;

height:90rpx;

position: absolute;

top:20rpx;

left:40rpx;

overflow:hidden;

}

.conent_img{

width:90rpx;

height:90rpx;

float:left;

margin-right:20rpx;

}

.conent_img image{

border-radius: 50rpx;

width:90rpx;

height:90rpx;

}

/* 标题 */

.conent_title{

float:left;

width:350rpx;

margin-top:12rpx;

}

.content_tt{

width:400rpx;

height:30rpx;

font-size: 30rpx;

overflow: hidden;

}

.conentt_ming{

float:left;

color:#000000;

font-family: '黑体';

margin-right:20rpx;

}

.conentt_admin{

float:left;

color:red;

font-size: 25rpx;

}

.content_date{

float:left;

font-size:25rpx;

margin-top:13rpx;

overflow: hidden;

}

 

.con_conent{

width:635rpx;

height:255rpx;

margin:0 auto;

position:absolute;

top:120rpx;

left:40rpx;

/* 线条 */

border-top:1rpx solid #eaeaea;

border-bottom:1rpx solid #eaeaea;

/* 线条end */

}

.conentt_ent{

width:635rpx;

margin:20rpx auto;

}

.conentt_ent view{

float:left;

}

.conentt_title{

display:inline-block;

font-size:26rpx;

 

}

.conett_strong{

font-size:30rpx;

color:#B70100;

}

 

.con_footer{

position:absolute;

left:40rpx;

bottom:0;

width:635rpx;

height:53rpx;

}

.conf_cont{

position: absolute;

right:30rpx;

}

.confot_zan , .confot_zhuan{

float:left;

width:120rpx;

height:30rpx;

margin-top:12rpx;

margin-left:5rpx;

font-size:25rpx;

}

.confotz_icon{

float:left;

margin-left:20rpx;

}

.confotz_text{

float:right;

margin-top:1rpx;

}

/* 中间内容部分END */

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值