小程序中携带cookie
- 在登录请求后读取 返回值的, header的cookie,并本地存储
wx.setStorageSync(“sessionid”, res.header[“Set-Cookie”]) - 在下一次请求的时候设置header,并写入cookie
header = {
‘content-type’: ‘application/x-www-form-urlencoded’,
‘cookie’:“SESSID=” + wx.getStorageSync(“sessionid”)
};
微信小程序中页面跳转
- wx.navigateTo():保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面
- wx.redirectTo():关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面
- wx.switchTab():跳转到 abBar 页面,并关闭其他所有非 tabBar 页面
- wx.navigateBack()关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages() 获取当前的页面栈,决定需要返回几层
- wx.reLaunch():关闭所有页面,打开到应用内的某个页面
微信小程序参数传值的方法
- 给 view 组件添加 data-*属性来传递我们需要的值,然后通过e.currentTarget.dataset 或onload 的 param 参数获取。但 data-名称不能有大写字母和不可以存放对象
- 设置 id 的方法标识来传值通过 e.currentTarget.id 获取设置的 id 的值,然后通过设置全局对象的方式来传递数值
- 在 navigator 中添加参数传值