1 /* value 的值 range 获取对象 */ 2 <view class='department-choose'> 3 4 <picker bindchange="binpicker" value='{{department}}' range='{{objectArray}}' range-key="departmentName" > 5 <text>{{departmentId == '' ? "请选择部门" : department}}</text> 6 <image src='/images/right.png' class='department-choose-img'></image> 7 </picker> 8 </view>
. 1 Data: { 2 . 3 ObjectArray: [], // this is null data acquired from the background . 4 departmentId: '', // Get the id value . 5 Department: '', // sector within the view by the value bound the 6 } . 7 . 8 // selected text . 9 binpicker (E) { 10 // Get the value argument . 11 the let pickerindex = e.detail.value 12 is // Get the inside contents of the array we need 13 is const = ObjectArray the this .data.objectArray ; 14 the this .setData ({ 15 departmentId: ObjectArray [pickerindex] .departmentId, // here deparmentId background is transmitted from the console AppData Id applet which can be seen 16 Department: ObjectArray [pickerindex] .departmentName // Get back to the transmission 17 }) 18 }, 19 // this is a submit button to submit in the process triggering event 20 is bindSubmitForm (E) { 21 is 22 is the let = departmentId the this .data.departmentId 23 is postRequest (employeeRegister, {}, RES => { 24 // here "departmentId" quotes the background of the incoming 25 "departmentId" : departmentId, 26 27 28 }) 29 30 }