微信小程序在两个之间传参类似js传递url拼接参数,举个例子来说吧
input自己设置参数
//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>
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 Page({ data: { motto: 'Hello', userInfo: {}, answer: stringAns, uesrname:'' //设置一下接收的变量 }, onLoad: function (option) { this.setData({ uesrname:option.uesrname }) },
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/6126.html