Component({ observers: { 'defaultPickData'(arr){ var idx =arr this.setData({ idx }) } }, /** * 组件的属性列表 */ properties: { listData: { type: Array, value: [], }, isShowPicker:{ type: Boolean, value: false, }, defaultPickData:{ type:Number, value:0 }, key:{ type:String, value:'' } }, /** * 组件的初始数据 */ data: { imageServerUrl: getApp().globalData.imageServerUrl, idx: 0, }, /** * 组件的方法列表 */ lifetimes: { ready :function(){ setTimeout(() => { var idx =this.data.defaultPickData this.setData({ idx }) },0) }, }, methods: { btn_fn(){ }, cancel(e){ console.log(e) this.triggerEvent('cancel',false) }, to_ok(e){ this.setData({ idx:e.currentTarget.dataset.index }) }, confirm(e){ this.setData({ isShowPicker:false }) this.triggerEvent('confirm',this.data.idx) } } })