Vue 路由 vue-router 传递参数与接收参数

1. 路由配置

该路由配置传递了两个参数  id 与 name

const routes = [{ path: '/user/:id/:name', component: User }]

2.接收参数

这里使用$route.params 是获取接收的参数

3.访问

http://localhost:8080/user/user_id/user_name

显示

Vue 路由 vue-router 传递参数与接收参数_第1张图片

4 router-link设置

1.拼接url模式

To User

2.声明模式

User

 

你可能感兴趣的:(Vue,vue.js)