目录

uniapp页面跳转带参数获取,需要注意在小程序和web下是不一样的

目录

uniapp页面跳转带参数获取,需要注意在小程序和web下是不一样的

const routes = getCurrentPages();

const route = routes[routes.length - 1];

let id = “”;

let active = “”;

//重点在小程序里和web里获取参数方法不一样

onMounted(() => {

const uniPlatform = uni.getSystemInfoSync().uniPlatform;

console.log(“当前平台===",uniPlatform); // app

let id = “”;//上个页面参数1

let active = “”;//上个页面参数2

if(uniPlatform===“web”){

id = route.$page.options.id;

active = route.$page.options.active;

}else{

id = route.options.id;

active = route.options.active;

}

console.log("===",active,id);

});