微信小程序在两个之间传参类似js传递url拼接参数,举个例子来说吧
input自己设置参数
1 2 3 4 5 6 7 8 9 | //index.wxml <form
bindsubmit= "formSubmit" bindreset= "formReset" class= "myform" > <text class= "prompt" >给自己起个名字吧</text> <input placeholder= "给自己起个名字吧" name= "uesrname" /> <!--<navigator url= "../logs/logs?title=我是index" >跳转到新页面</navigator> 之间传参--> <!--<navigator url= "../logs/logs?title=我是index" redirect>在当前页打开</navigator> --> <button form-type= "submit" type= "primary" size= "mini" >确定</button> <button form-type= "reset" type= "warn" size= "mini" >重置</button> </form> |
1 2 3 4 5 6 7 8 9 10 | formSubmit: function (e){ var da =
e.detail.value; var qu =
da.uesrname; this .setData({ username:qu }), wx.navigateTo({ url: '../logs/logs?uesrname=' +qu
//qu是上面input输入的值 }) }, |
logs.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | //logs.js Page({ data: { motto: 'Hello' , userInfo: {}, answer: stringAns, uesrname: '' //设置一下接收的变量 }, onLoad: function (option) { this .setData({ uesrname:option.uesrname }) }, |