Vue 获取参数的方式

Vue 获取参数的方式

总是找不到自己想要的…

有两种方式
1. /test/test?id=1
直接在页面 this.$route.query.id

2. /test/test/1
在路由配置页面

 const router = new VueRouter({
    routes: [
        { 
            path: '/test/test/:id', 
            component: Test, 
            props: true			//必须写 启动props参数传递 
       }
   ]})

在页面 this.$route.params.id

有缘再见 哈哈

你可能感兴趣的:(vue)