2019独角兽企业重金招聘Python工程师标准>>>
A页面:
.wxml文件
<view class="flex-wrp"><text style="width: 32%;">选择城市</text><input style="width: 68%;" type="text" bindtap="city" placeholder="请选择城市" value="{{cityName}}"/></view>
.js文件
Page({data: {cityName:"深圳" #用来回传的关键字,默认深圳},city: function(e){wx.navigateTo({url: '../city/city'})}})
A页面跳转B页面之后返回:
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();},