vue-router路由参数的传递

107 阅读1分钟

1.必须在路由内加入路由的name

2.必须在path后加/:传递参数

3.传递参数和接收参数有两种方式

第一种方式:
<router-link :to="{ name: 'helloworld', params: { worldmsg: '你好世界' } }">HelloWorld</router-link> 读取参数:$router.params.xxx
方式:===/helloworld/你好世界

第二种方式:
<router-link :to="{ name: 'helloworld', query: { msg: '你好世界' } }">HelloWorld</router-link> 方式:===/helloworld?name=XX&count=xxx