在控制台看似没毛病,但是传递到后台的全是下标值(index那边的默认的从0开始的数值),试了无数次都是没用。。。不知道如何解决。
你好,问题未复现。请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
wxml:代码
<form bindsubmit=“formSubmit” report-submit=“true”>
<view class=“lb”>
<view class=“leibie”>选择科目</view>
<picker name=“orderitem” mode=“selector”
bindchange=“bindPickerChange” value="{{index}}" range="{{array}}">
<view class=“picker”>
<view class=“array”>{{array[index]}}</view>
</view>
</picker>
</view>
<view class=“lb”>
<view class=“leibie”>选择年级</view>
<picker name=“ordernianji” mode=“selector”
bindchange=“bindPickerChange1” value="{{index1}}" range="{{nianjiArray}}">
<view class=“picker”>
<view class=“array”>{{nianjiArray[index1]}}</view>
</view>
</picker>
</view>
<button class=“btn0” style=“background-color:#01bc24;color:#ffffff;” bindtap=“click” button type=“default” form-type=“submit”>发布</button>
</form>
JS代码:
Page({
data: {
array: [‘点击选择’,‘语文’, ‘数学’, ‘英语’, ‘物理’, ‘化学’, ‘生物’, ‘地理’, ‘小语种’,‘书法’],
index: 0,
nianjiArray: [‘点击选择’,‘三年级’, ‘四年级’, ‘五年级’, ‘六年级’, ‘初一’, ‘初二’, ‘初三’, ‘高一’,‘高二’,‘高三’],
index1: 0,
},
bindPickerChange: function (e) {
console.log(‘picker发送选择改变,携带值为’, this.data.array[e.detail.value])
this.setData({
index: e.detail.value
})
},
bindPickerChange1: function (e) {
console.log(‘picker发送选择改变,携带值为’, this.data.nianjiArray[e.detail.value])
this.setData({
index1: e.detail.value
})
},
})
谢谢回复