[转] 微信小程序 页面跳转 传递参数
本文转自:http://blog.csdn.net/qq_31383345/article/details/52795212
微信小程序的页面跳转,页面之间传递参数笔记.
先上demo图:
为了简化逻辑,所以index.wxml里面只写了两个text.既然是跳转,那就还有其他页面.
目录如下:
三个页面,但是代码很简单.直接上代码.
- <span style="font-size:24px;"><!--index.wxml-->
- <view class="btn-area">
- <navigator url="../navigator/navigator?title=我是navigate" >跳转到新页面</navigator>
- <navigator url="../redirect/redirect?title=我是redirect" redirect>在当前页打开</navigator>
- </view></span>

<span style="font-size:24px;"><!--index.wxml-->
<view class="btn-area">
<navigator url="../navigator/navigator?title=我是navigate" >跳转到新页面</navigator>
<navigator url="../redirect/redirect?title=我是redirect" redirect>在当前页打开</navigator>
</view></span>
index.wxml中的URL就是跳转的页面路径.上面代码中就是navigator目录下的navigator页面,title是参数. navigator下redirect属性是值在当前页打开.如果不加redirect就是跳转到新页面.都可以携带参数. navigator下redirect属性是值在当前页打开.如果不加redirect就是跳转到新页面.都可以携带参数.
- <span style="font-size:24px;"><!--navigatort.wxml-->
- <view style="text-align:center"> {{title}} </view></span>

<span style="font-size:24px;"><!--navigatort.wxml-->
<view style="text-align:center"> {{title}} </view></span>
在navigatort.wxml中通过js代码可以获取到title,代码如下
//navigatort.js
- Page({
- onLoad: function(options) {
- this.setData({
- title: options.title
- })
- }
- })

Page({
onLoad: function(options) {
this.setData({
title: options.title
})
}
})
- <span style="font-size:24px;"><!--redirect.wxml-->
- <view style="text-align:center"> {{title}} </view></span>

<span style="font-size:24px;"><!--redirect.wxml-->
<view style="text-align:center"> {{title}} </view></span>
- <span style="font-size:24px;">//redirect.js
- Page({
- onLoad: function(options) {
- this.setData({
- title: options.title
- })
- }
- })</span>

<span style="font-size:24px;">//redirect.js
Page({
onLoad: function(options) {
this.setData({
title: options.title
})
}
})</span>
最后上两张跳转后的图.
1.跳转到新页面
2.在原来的页面打开
有没有发现一个细节,在原来的页面打开是不会出现返回按钮的,而跳转到新页面后会出返回按钮.
这是因为我写了两个页面.如果indexwxml不是一级页面,这里都会出现返回按钮.
当然返回的结果是不一样的:
1.跳转到新页面,返回是回到之前的页面;
2.在原来页面打开,返回是回到上一级页面.
http://blog.csdn.net/qq_31383345
[转] 微信小程序 页面跳转 传递参数的更多相关文章
- 微信小程序 页面跳转传递数据
点击view 跳转页面 <view class="album_image" data-album-obj="{{item}}" bindtap=" ...
- 微信小程序页面跳转方法总结
微信小程序页面跳转目前有以下方法(不全面的欢迎补充): 1. 利用小程序提供的 API 跳转: // 保留当前页面,跳转到应用内的某个页面,使用wx.navigateBack可以返回到原页面.// 注 ...
- 微信小程序-页面跳转与参数传递
QQ讨论群:785071190 微信小程序页面跳转方式有很多种,可以像HTML中a标签一样添加标签进行跳转,也可以通过js中方法进行跳转. navigator标签跳转 <view class=& ...
- 微信小程序——页面跳转及传参
小程序页面跳转 微信小程序的页面跳转依然是以传统的请求转发和请求重定向为主,tabbar的存在,有TAB页面的跳转. 为了微信小程序的简介方便,规定页面路径只能是十层,应尽量避免过多的交互方式. 1. ...
- 微信小程序页面跳转导航wx.navigateTo和wx.redirectTo
}) wx.redirectTo(OBJECT) 关闭当前页面,跳转到应用内的某个页面. 还是用上面的三张图示作为例子,当使用wx.redirctTo接口跳转页面时,原来的页面将被删除掉,当然,这是小 ...
- 直击--vue项目微信小程序页面跳转web-view不刷新-根源
背景 最近项目需要适配小程序,项目是使用了vue开发的网站,其中改造方式是,每个页面都使用小程序创建一个页面通过web-view来显示指定页面的. 在没有使用小程序时,路由跳转时,刷新页面等等,这个是 ...
- 微信小程序页面跳转的三种方式总结
原文链接 https://blog.csdn.net/zgmu/article/details/72123329 首先我们了解到,小程序规定页面路径只能有五层,所以我们尽量避免多层级的页面跳转 页面跳 ...
- 微信小程序页面跳转方法和携带参数详解
1.页面跳转方式 (1)标签跳转 open-type的属性值对应api里的用法即wx.的用法 1 <navigator url="/page/navigate/navi ...
- 微信小程序页面跳转 的几种方式
最近在做微信小程序,碰到页面跳转的问题,总结一下页面之间跳转的方式 一.wx.navigateTo(OBJECT) 这是最普遍的一种跳转方式,其官方解释为:“保留当前页面,跳转到应用内的某个页面” 类 ...
随机推荐
- Linux日常命令使用记录
scp在跨机器复制的时候为了提高数据的安全性,使用了ssh连接和加密方式,如果机器之间配置了ssh免密码登录,那在使用scp的时候密码都不用输入. 在服务器104.238.161.75上操作,将服务器 ...
- MVN package install error javac: invalid target release: 1.8
现象:---------------------------------[ERROR] Failure executing javac, but could not parse the error:j ...
- C# LINQ(8)
回顾之前的代码都是LINQ自行推断类型.其实LINQ在查询的结束是可以动态创建类型. , , , , , , , , , , }; var list = from num in intArray &a ...
- The method identifyUser(Arrays.asList("group001"), String, new HashMap<>()) is undefined for the type AipFace
在使用百度云的人脸识别sdk时遇到了这个错误,网上百度不到解决的方法,当我浏览百度云的时候发现了这个 于是考虑到版本可能更新,出现了新的函数代替旧的函数,于是去查文档,文档链接如下 https://c ...
- width:100%以什么为基准的测试
起初是遇到这样一个问题:当盒模型设为box-sizing:border-box;(移动端上经常这么干).子盒子的width:100%,子盒子的width等于父盒子contend的长度还是condend ...
- Haproxy配置之URL重写,支持websocket
配置文件位置:/etc/haproxy/haproxy.cfg Reqrep 正则重写 配置详情: Frontend App *: acl uri_api path_beg /api/ acl uri ...
- css3 超出文本...显示
width: 250px 或者 100%; max-width: 285px; overflow: hidden; display: inline-block; white-space: nowrap ...
- P2048 [NOI2010]超级钢琴
传送门 考虑维护前缀和 $sum[i]$ 那么对于每一个位置 $i$ ,左端点为 $i$ 右端点在 $[i+L-1,i+R-1]$ 区间的区间最大值容易维护 维护三元组 $(o,l,r)$ ,表示左端 ...
- ElementUI 时间控件
<template> <div class="block"> <span class="demonstration">默认& ...
- AtCoder Beginner Contest 113 A
A - Discount Fare Time limit : 2sec / Memory limit : 1024MB Score: 100 points Problem Statement Ther ...