const app = getApp(); Component({ data:{ productList:[], prductIndex:'', }, lifetimes: { attached: function () { this.getProductName() }, moved: function () { }, detached: function () { }, }, methods:{ getProductName(){ app.requestP({ url: '/showApi/getProductList', method: 'get', needToken:false }).then(res=>{ this.setData({ productList:res.data.data, prductIndex:res.data.data[0] }) }).catch(err=>{ app.showToptip(this,'error',err.data.msg); }) }, goPage1(){ console.log(112) this.triggerEvent('goPage1', {}, {}) }, } })