龙江网站设计制作,徐汇企业网站建设,关于网站策划书描述准确的有,莲都区建设局网站一、需求#xff1a;
tabbar之间跳转页面时#xff0c;需要传递一个参数。 官方文档明确说明: 跳转tabBar栏的页面只能使用 uni.switchTab 并且url 路径后面不能传递参数。 二、解决方法#xff1a;
方法1#xff1a;setStorageSync(本地缓存)
//index.vue 页
onclick …一、需求
tabbar之间跳转页面时需要传递一个参数。 官方文档明确说明: 跳转tabBar栏的页面只能使用 uni.switchTab 并且url 路径后面不能传递参数。 二、解决方法
方法1setStorageSync(本地缓存)
//index.vue 页
onclick () {存起来在另一个页面中获取.uni.setStorageSync(myIndex, value);uni.switchTab({url:/pages/user/user})
}//user.vue 页在onShow中从本地缓存中获取出来,进行相关操作
onShow() {const myIndex uni.getStorageSync(myIndex);console.log(myIndex)
}方法2使用全局变量
main.js 定义全局变量
Vue.prototype.$name ;页面1 name.vue this.$name chuanzhi;uni.switchTab({url:/pages/index/index})页面2index.vue 注意一定要放在onShow生命周期里面及时更新数据因为tabBar会有缓存机制此时再次进入页面onLoad不会执行
onShow(){this.info.name this.$name//赋值取得参数}此时this.info.name 就是name.vue页面传递过来的参数