这个是传参数
Component({
properties: {},
data: {
phone:'',
},
lifetimes: {
created: function () {},
attached: function () {
console.info("页面加载");
},
detached: function () {
console.info("页面卸载");
},
},
methods: {
inputPhone:function(){
},
goUserPwd:function(){
let phone = this.data.phone;
console.log(phone)
const urlData = '/pages/dengluyeshurumima/component?phone='+encodeURIComponent(phone);
console.log('urlData====',urlData)
wx.navigateTo({
url: urlData,
})
}
},
});
这个是接收参数
Component({
onLoad: function(options) {
const phone = JSON.parse(options.phone);
console.log('phone===',phone);
this.setData({
phone:phone
})
console.log(this.data.phone)
},
properties: {},
data: {phone:''},
lifetimes: {
created: function () {},
attached: function () {
console.info("页面加载");
},
detached: function () {
console.info("页面卸载");
},
},
methods: {
goUserInfo:function(){
wx.navigateTo({
url: '/pages/lanhu_xinxiheduiye/component',
})
}
},
});
onLoad属于Page的生命周期回调,Component的生命周期没有onLoad
可考虑改为Page,而不是Component
参考:https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html