微信小程序页面跳转时传参数
2017-07-17 17:53
507 查看
1、pagejump.wxml:
<view class="page">
<button type="default" bindtap="onBtnClick">跳转到新页面</button>
</view>
2、pagejump.js
Page({
data: {
lastval: {},
showBtn: false,
},
onLoad: function (options) {
// 生命周期函数--监听页面加载
var that = this;
console.log('onLoad is invoked');
console.log(options);
that.setData({
lastval: options.val,
})
},
onBtnClick: function () {
var that = this;
console.log('onBtnClick');
wx.navigateTo({
url: '../home/home?tp=2&index=hello bright&showBtn=false',
success: function (res) {
// success
console.log('onBtnClick success() res:');
},
fail: function () {
// fail
console.log('onBtnClick fail() !!!');
},
complete: function () {
console.log('onBtnClick complete() !!!');
// complete
}
})
}
})
3、home.wxml:
<view class="test">新页面新页面tp=={{tp}}</view>
<view class="test">新页面新页面showBtn=={{showBtn}}</view>
<view class="test">新页面新页面index=={{index}}</view>
4、home.js:
Page({
data: {
tp:'',
showBtn: '',
index:'',
},
onLoad: function (options) {
// 生命周期函数--监听页面加载
var that = this;
console.log('onLoad is invoked');
that.setData({
tp: options.tp,
index: options.index,
showBtn: (options.showBtn == "true" ? true : false),
});
console.log("tp="+tp);
}
})
<view class="page">
<button type="default" bindtap="onBtnClick">跳转到新页面</button>
</view>
2、pagejump.js
Page({
data: {
lastval: {},
showBtn: false,
},
onLoad: function (options) {
// 生命周期函数--监听页面加载
var that = this;
console.log('onLoad is invoked');
console.log(options);
that.setData({
lastval: options.val,
})
},
onBtnClick: function () {
var that = this;
console.log('onBtnClick');
wx.navigateTo({
url: '../home/home?tp=2&index=hello bright&showBtn=false',
success: function (res) {
// success
console.log('onBtnClick success() res:');
},
fail: function () {
// fail
console.log('onBtnClick fail() !!!');
},
complete: function () {
console.log('onBtnClick complete() !!!');
// complete
}
})
}
})
3、home.wxml:
<view class="test">新页面新页面tp=={{tp}}</view>
<view class="test">新页面新页面showBtn=={{showBtn}}</view>
<view class="test">新页面新页面index=={{index}}</view>
4、home.js:
Page({
data: {
tp:'',
showBtn: '',
index:'',
},
onLoad: function (options) {
// 生命周期函数--监听页面加载
var that = this;
console.log('onLoad is invoked');
that.setData({
tp: options.tp,
index: options.index,
showBtn: (options.showBtn == "true" ? true : false),
});
console.log("tp="+tp);
}
})
相关文章推荐
- 微信小程序页面跳转传递Json对象参数
- 详解微信小程序 页面跳转 传递参数
- 微信小程序 页面跳转 传递参数
- 微信小程序之页面跳转和参数传递的实现
- 微信小程序 页面跳转 传递参数
- 微信小程序页面带参数跳转及接收参数内容navigator
- 微信小程序页面带参数跳转及接收参数内容navigator
- 微信小程序 页面跳转navigator与传递参数
- 微信小程序详解——页面之间的跳转方式【路由】和参数传递
- 微信小程序开发之页面跳转并携带参数
- 微信小程序的页面跳转和参数传递,页面生命周期
- 微信小程序 页面跳转 传递参数
- [微信小程序]页面跳转对象参数的传递方法
- 微信小程序——页面跳转传递参数(实体,对象)
- [转] 微信小程序 页面跳转 传递参数
- 微信小程序之页面跳转和参数传递
- 微信小程序详解——页面之间的跳转方式【路由】和参数传递
- 微信小程序页面跳转功能之从列表的item项跳转到下一个页面的方法
- 微信小程序 页面跳转传递数据
- 微信小程序之点击列表的item带参数跳转界面