显示传参模式 get
import { useRouter } from 'vue-router';
const router = useRouter();
let skipEdit = (key: string, res: any) => {
router.push({
path: 'editRole',
query: {
key: key,
body: res,
},
});
};
import { useRoute } from 'vue-router';
setup() {
const route = useRoute();
let res: any = ref({});
let get = async () => {
res.value = await getParticulars({ categoryName: route.query.name
};
onMounted(get);
return {
columns,
get,
res,
};
},
隐式传参模式 post
import { useRouter } from 'vue-router';
const router = useRouter();
let skipEdit = (key: string, res: any) => {
router.push({
name: 'EditRole',
params: {
key: key,
body:JSON.stringify(res),
},
});
};
setup() {
const route: any = useRoute();
if (route.params.body) {
let obj = JSON.parse(route.params.body);
console.log(JSON.parse(obj));
}
return {
date,
};
},