WeChat applet explains page jump and return and returns data
A page:
.wxml file
<view class="flex-wrp"> <text style="width: 32%;">选择城市</text> <input style="width: 68%;" type="text" bindtap="city" placeholder="请选择城市" value="{{cityName}}"/> </view>
.js file
Page({ data: { cityName:"深圳" #用来回传的关键字,默认深圳 }, city: function(e){ wx.navigateTo({ url: '../city/city' }) } })
After page A jumps to page B, it returns:
cityNameClick: function (event) { var cityName = event.currentTarget.dataset.cityname; console.log(cityName); var pages = getCurrentPages(); var currPage = pages[pages.length - 1]; //当前页面 var prevPage = pages[pages.length - 2]; //上一个页面 //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 prevPage.setData({ cityName: cityName }) wx.navigateBack(); },
Thank you for reading, I hope it can help everyone, thank you for your support of this site!
For more articles related to WeChat applet page jump and return and return data, please pay attention to the PHP Chinese website!