import {getEventParam} from "../../utils/utils"; import {logicStatus} from "../../model/enum"; Component({ properties: { label: String, pickData: { type: Array, value: [ {dictLabel: '是', dictValue: logicStatus.YES + ""}, {dictLabel: '否', dictValue: logicStatus.NO + ""} ] }, key: { type: String, value: 'dictLabel' }, value: { type: String, value: 'dictValue' }, emitKey: String, index: String, placeholder: String }, observers: { index: function (index) { this.setData({ position: this.findIndex(this.data.pickData, index) }) } }, data: { position: -1 }, methods: { findIndex(arr, value) { return arr.findIndex(item => item.dictValue === value); }, bindChange(e) { this.setData({ position: getEventParam(e, 'value') }, () => { this.triggerEvent('change', { [this.data.emitKey]: this.data.pickData[this.data.position][this.data.value] }) }) }, } });