WeChat applet page jump and return and return data

高洛峰
Release: 2017-02-25 09:27:59
Original
2406 people have browsed it

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>
Copy after login

.js file

Page({
 data: {
  cityName:"深圳"  #用来回传的关键字,默认深圳
 },
 city: function(e){
  wx.navigateTo({
    url: &#39;../city/city&#39;
  })
 }

})
Copy after login

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();
 },
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!