- 如何让问卷遍历所有选项?
[图片] 你好,我在做一个问卷类型的项目,项目要求将选择问题的choice_id拼接成字符串提交到后端,问题的格式如下: [图片] 其中,选项的格式如下: [图片] 其中,我给所有的选项加上false的选项 for (var i = 0; i < res.data.data.length; i++) { res.data.data[i].choice.map(function (value) { value.checked = false }) } 现在希望点击按钮后将按钮选择为true的值遍历,然后将这些值输出 for (var i = 0; i < this.data.data.length; i++) { this.data.data[i].choice.forEach(function (item,index) { console.log(item); console.log(index); }) } 我这里只能将这些值输出 [图片] 希望大佬指点,如果这种方法不行,我说一下需求,希望大佬给点方法 需求:问卷有单选与多选题,单选只能4个选一个,多选可以多选,每个选项有独立且不同的choice_id,我要把所有的选择的choice_id选出来 谢谢,麻烦了
2020-03-10 - 可以排序的表格如何写?做小程序才没几天,求助
[图片] 最多写出这样一个表格,排序是不会,求大佬解答 <view class="table"> <view class="tr bg-w"> <view class="th" bindtap="sortT">Time</view> <view class="th">Status</view> <view class="th ">Method</view> </view> <block wx:for="{{listData}}" wx:key="{{time}}"> <view class="tr bg-g" wx:if="{{index % 2 == 0}}"> <view class="td">{{item.time}}</view> <view class="td">{{item.status}}</view> <view class="td">{{item.method}}</view> </view> <view class="tr" wx:else> <view class="td">{{item.time}}</view> <view class="td">{{item.status}}</view> <view class="td">{{item.method}}</view> </view> </block> </view> .table { border: 0px solid darkgray; padding: 20rpx 10rpx; } .tr { display: flex; width: 100%; justify-content: center; height: 3rem; align-items: center; } .td { width:50%; justify-content: center; text-align: center; } .bg-w{ background: #0089dd; opacity: 0.6; } .bg-g{ background: #E6F3F9; } .th { width: 50%; justify-content: center; background: #0089bb; color: #fff; display: flex; height: 3rem; align-items: center; } Page({ data:{ listData: [ { "time": "time1", "status": "status1", "method": "method1" }, { "time": "time2", "status": "status2", "method": "method2" }, { "time": "time3", "status": "status3", "method": "method3" }, { "time": "time4", "status": "status4", "method": "method4" }, { "time": "time5", "status": "status5", "method": "method5" }, { "time": "time6", "status": "status6", "method": "method6" } ] }, onLoad: function () { console.log('onLoad') }, onShow(){ }, sortT:function (e) { } })
2020-03-05