Component({ properties: { hoteldatas: { type: null }, show: { type: null }, start: { type: null }, end: { type: null } }, data: { language: '', }, // 私有数据,可用于模板渲染 lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached() { let language = wx.getStorageSync('langIndex'); this.setData({ 'language': language.en}); }, moved() {}, detached() {}, }, // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached() { }, // 此处attached的声明会被lifetimes字段中的声明覆盖 ready() { }, pageLifetimes: { // 组件所在页面的生命周期函数 show() {}, hide() {}, resize() {}, }, methods: { gotoHomePage(e) { let value = e.currentTarget.dataset.item; wx.navigateTo({ url: '/packageC/hotel/HotelHome/HotelHome?id=' + value.id + '&city=' + value.address.city + '&start=' + (this.data .start ? this.data .start : '') + '&end=' + (this.data.end ? this.data.end : '') }); }, goChooseRoom(e) { let value = e.currentTarget.dataset.item; wx.navigateTo({ url: '/packageC/hotel/HotelChooseRoom/HotelChooseRoom?id=' + value.id + '&start=' + (this.data.start ? this.data .start : '') + '&end=' + (this.data.end ? this.data.end : '') }); } } });