const app = getApp()
Page({
data: {
winHeight: 0
},
//监听传值,后面自己做处理了
cityTap(e) {
console.log(e)
const cityName = e.detail.cityname
// const cityName = e.currentTarget.dataset.cityName
console.log('选择城市为:' + cityName)
console.log('此处选择后,跳转页面,将城市名传过去显示到页面')
this.setData({
cityName:cityName
})
wx.setStorageSync('cityName', cityName)
wx.switchTab({
url: '/pages/index/index',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const win = wx.getSystemInfoSync()
console.log(win)
this.setData({
winHeight: win.windowHeight
})
}
})
url: '/pages/index/index?cityName='+ 'cityName',// 跳转到首页后再onload里的opthions对象可以获取到cityName的值,这样子选好的城市就可以展示到首页了
求帮忙