How to get the value of the selected radio in the mini program. The following is my code. Three swipers are used to carry three questions. After selecting the three questions, the selection result pops up. How to implement it
/!-- index.wxml --> 第一题 第二题 第三题 // index.js var app = getApp() Page({ data: { /** * 页面配置 */ winWidth: 0, winHeight: 0, // tab切换 currentTab: 0, value: [] }, onLoad: function() { var that = this; /** * 获取系统信息 */ wx.getSystemInfo({ success: function(res) { that.setData({ winWidth: res.windowWidth, winHeight: res.windowHeight }); } }); }, /** * 滑动切换tab */ bindChange: function(e) { var that = this; that.setData({ currentTab: e.detail.current }); }, /** * 点击radio切换 */ swiperChange: function(e){ var that = this; var radioValue = e.detail.value; that.setData({ value : radioValue }) console.log(that.data.value); if(that.data.currentTab>=2){ wx.navigateTo({ url: '../page3/page3', }); }else{ that.setData({ currentTab: that.data.currentTab + 1 }); } } }) /* index.wxss */ .swiper-tab{ width: 100%; border-bottom: 2rpx solid #777777; text-align: center; line-height: 80rpx; } .swiper-tab-list{ float: left; font-size: 30rpx; width: 100%; color: #777777; display: none; } .on{ color: #da7c0c; border-bottom: 5rpx solid #da7c0c; display: block; } .swiper-box{ display: block; height: 100%; width: 100%; overflow: hidden; } .swiper-box view{ text-align: center; } radio{ display: none; } .option{ border: 1px solid #ffe131; display: block; text-align: center; margin: 10% auto; width: 80%; }
Official demo