兄弟们之前咱们直接使用
router.push({
name: "/home",
params: {
type: '类型',
content: '内容',
},
});
const route = useRoute()
let types = route.params.types
let content = route.params.content
在4.14后的版本中都取消掉了,真的是醉了😅😅😅
https://github.com/vuejs/router/commit/e8875705eb8b8a0756544174b85a1a3c2de55ff6
现在想用params 来进行传参那么路由配置中必须得写上后,params才能识别到,这还不然用query来传参哦
以下是写法params之一
{
path: "home/:types/:content",
name: "/home",
meta: {
title: "主页",
needLogin: true,
keepAlive: false,
},
component: () => import("@/views/demo/home/home.vue"),
},
query就没有那么花里胡哨了,还得在路由中配置
{
path: "home",
name: "/home",
meta: {
title: "主页",
needLogin: true,
keepAlive: false,
},
component: () => import("@/views/demo/home/home.vue"),
},