1. url pass value
list.wxml: <view class="playIcon"> <image src="../../iconfont/play_init.png" bindtap="playAudio" data-songid="{{song.song_id}}"></image> </view> list.js: playAudio: function (event) { let songid = event.currentTarget.dataset.songid; var that = this; wx.navigateTo({ url: '/pages/listDetail/listDetail?title=' + songid, }) } listDetail: onLoad: function (options) { var that = this; console.log('options',options) }
2.app.globalData sets global variables
app.js: set global variables App({ globalData: { userInfo: null, host:'http://localhost:8000' } }) index.js: const app = getApp() app.globalData = 'You can also set values here' , console.log(app.globalData.host)
3.setStorage() /getStorage() Write the value in the local cache, the maximum support is 10M, you can store some text and the like, just audio and video
list.js: Store the value in the local cache wx.setStorage('title',data) listDetail.js: Get value from local cache let info = wx.getStorage('title') console.log('info',info)