var toastNum = 3 var pageData = { bindPickerChange: function (e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ index: e.detail.value }) }, } pageData.data = { array: ['success', 'success_no_circle', 'info', 'warn', 'waiting', 'cancel', 'download', 'search', 'clear'], index: 0, } for(var i = 0; i <= toastNum; ++i) { pageData.data['toast'+i+'Hidden'] = true; (function (index) { pageData['toast'+index+'Change'] = function(e) { var obj = {} obj['toast'+index+'Hidden'] = true; this.setData(obj) } pageData['toast'+index+'Tap'] = function(e) { var obj = {} obj['toast'+index+'Hidden'] = false this.setData(obj) } })(i) } Page(pageData)
|