微信小程序怎样制作tab页面切换,代码是什么
Admin 2022-11-19 群英技术资讯 640 次浏览
具体内容如下
html 页面
<view class="bgwhite"> <scroll-view scroll-x="true"> <view class="width100 row nowrap"> <view class="f32 c666 p-tb-20 p-lr-30 {{currentData == 0 ? 'topic' : ''}}" data-current="0" bindtap='checkCurrent'>第1题</view> <view class="f32 c666 p-tb-20 p-lr-30 {{currentData == 1 ? 'topic' : ''}}" data-current="1" bindtap='checkCurrent'>第2题</view> <view class="f32 c666 p-tb-20 p-lr-30 {{currentData == 2 ? 'topic' : ''}}" data-current="2" bindtap='checkCurrent'>第3题</view> <view class="f32 c666 p-tb-20 p-lr-30 {{currentData == 3 ? 'topic' : ''}}" data-current="3" bindtap='checkCurrent'>第4题</view> <view class="f32 c666 p-tb-20 p-lr-30 {{currentData == 4 ? 'topic' : ''}}" data-current="4" bindtap='checkCurrent'>第5题</view> <view class="f32 c666 p-tb-20 p-lr-30 {{currentData == 5 ? 'topic' : ''}}" data-current="5" bindtap='checkCurrent'>第6题</view> </view> </scroll-view> </view> <swiper current="{{currentData}}" class='width100' style="height:600px;" duration="300" bindchange="bindchange"> <swiper-item> <view class="m-lr-20"> <view class="row p-t-30 p-b-10"> <view class="radio_singel f22 p-lr-10">单选</view> <view class="m-l-20 weight500 f28">题目1</view> </view> <radio-group bindchange="radioChange"> <label class="row alignitems bgwhite p-tb-25 p-lr-20 radius15 m-t-20"> <view class="weui-cell__hd"> <radio checked="true" color="#1989f9"/> </view> <view class="f30 weight500 m-l-10">A、1111</view> </label> <label class="row alignitems bgwhite p-tb-25 p-lr-20 radius15 m-t-20"> <view class="weui-cell__hd"> <radio color="#1989f9"/> </view> <view class="f30 weight500 m-l-10">B、2222</view> </label> <label class="row alignitems bgwhite p-tb-25 p-lr-20 radius15 m-t-20"> <view class="weui-cell__hd"> <radio color="#1989f9"/> </view> <view class="f30 weight500 m-l-10">C、3333</view> </label> <label class="row alignitems bgwhite p-tb-25 p-lr-20 radius15 m-t-20"> <view class="weui-cell__hd"> <radio color="#1989f9"/> </view> <view class="f30 weight500 m-l-10">D、4444</view> </label> </radio-group> </view> </swiper-item> <swiper-item> <view class="m-lr-20"> <view class="row p-t-30 p-b-10"> <view class="radio_singel f22 p-lr-10">单选</view> <view class="m-l-20 weight500 f28">题目2</view> </view> <video src="" style="width:100%;"></video> <radio-group bindchange="radioChange"> <label class="row alignitems bgwhite p-tb-25 p-lr-20 radius15 m-t-20"> <view class="weui-cell__hd"> <radio checked="true" color="#1989f9"/> </view> <view class="f30 weight500 m-l-10">A、1111</view> </label> <label class="row alignitems bgwhite p-tb-25 p-lr-20 radius15 m-t-20"> <view class="weui-cell__hd"> <radio color="#1989f9"/> </view> <view class="f30 weight500 m-l-10">B、2222</view> </label> <label class="row alignitems bgwhite p-tb-25 p-lr-20 radius15 m-t-20"> <view class="weui-cell__hd"> <radio color="#1989f9"/> </view> <view class="f30 weight500 m-l-10">C、3333</view> </label> <label class="row alignitems bgwhite p-tb-25 p-lr-20 radius15 m-t-20"> <view class="weui-cell__hd"> <radio color="#1989f9"/> </view> <view class="f30 weight500 m-l-10">D、4444</view> </label> </radio-group> </view> </swiper-item> <swiper-item> </swiper-item> <swiper-item> </swiper-item> <swiper-item> </swiper-item> </swiper> <view class="footer p-tb-25"> <view class="m-lr-30 row just-btw"> <view class="row alignitems" bindtap="prevClick"> <image src="../../images/prev_icon.png" mode="aspectFit" style="width:48rpx;height:42rpx;"></image> <view class="f36 weight500 m-l-10">上一题</view> </view> <view class="jiaojuanbtn f30 white p-tb-20">交卷</view> <view class="row alignitems" bindtap="nextClick"> <view class="f36 weight500 m-r-10">下一题</view> <image src="../../images/next_icon.png" mode="aspectFit" style="width:48rpx;height:42rpx;"></image> </view> </view> </view>
css样式
.topic{ position: relative; color:#000; } .topic::before{ position: absolute; content:""; width:80rpx; height:6rpx; background: #1989f9; border-radius: 20rpx; bottom: 0; left:50%; transform: translateX(-50%); } .radio_singel{ background: #e6f7ff; border:1px solid #91d4fe; color:#1890ff; } .footer{ position: fixed; bottom: 0; background-color: #fff; left:0; right:0; }
js 页面
data: { currentData:0, }, //获取当前滑块的index bindchange(e){ const that = this; that.setData({ currentData: e.detail.current }) }, //点击切换,滑块index赋值 checkCurrent(e){ const that = this; if (that.data.currentData === e.target.dataset.current){ return false; }else{ that.setData({ currentData: e.target.dataset.current }) } }, //上一题 prevClick(){ var currentData = this.data.currentData - 1 if(currentData + 1 == 0){ wx.showToast({ title: '这是第1题了', }) }else{ this.setData({ currentData:currentData }) } }, //下一题 nextClick(){ this.setData({ currentData:this.data.currentData + 1 }) },
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
本篇文章给大家介绍在Vue项目中如何新建一个路由页面,希望对需要的朋友有所帮助!具体方法步骤如下:我们现在要新建一个测试页面,命名为Test.vue1:在components底下新建Test.vue<
现在很多商品都有售后评价,那么五星好评的功能是怎样实现的呢?这篇文章就给大家分享一下用用js实现简易的五星好评功能,实现效果及代码如下,感兴趣的朋友就继续往下看吧。
这篇文章主要介绍了Vue组件复用和扩展,对vue感兴趣的同学,可以参考下
JS自带一套内存管理引擎,负责创建对象、销毁对象,以及垃圾回收,下面这篇文章主要给大家介绍了关于JavaScript垃圾回收机制的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考下
目前Nodejs开发中有很多痛点,其中有一个是修改完代码以后需要我们重启服务才能看到效果。这样一次次的杀进程、重启,杀进程、重启很让人头大。程序员是最痛恨重复工作的物种,之前有了解过的同学可能知道 forever 。 forever 可以帮我们解决上面的问题,通过对资源变化的检测做到变化后自动重启。开发阶段我们使用 nodefile.js 来启动另外由于Nodejs的单线程,任何异常都会导致整个
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008