const app = getApp(); Page({ data: { selectArray: [], // 性别-数据 index: '', // 性别-下标、 sex: '', // 性别 }, onLoad: function (options) { var that =this; // 性别 ajax let p_url = 'public/paramsgather?type=sex'; let p_data = { // pid: '0' }; app.postRequest(p_url, p_data, function (res) { // 性别 ajax if (res.code == 201) { // console.log(res.data); that.setData({ selectArray: res.data }) } // let dictObject = res.data; // // 对象转成数组 // var createArr = [] // for (let i in dictObject) { // createArr.push(dictObject[i]); // } }) }, onShow: function () { }, GenderEvent: function (e) { // 性别 单项选择器 // console.log(this); // console.log(e); // console.log(this.data.selectArray[e.detail.value]); // console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ index: e.detail.value, sex: e.detail.value }) }, })