vue动态路由传值和get传值
2020-05-12 本文已影响0人
lookphp
1、动态路由传值
2、get传值
不同路由传值:动态路由
1、配置动态路由,main.js
const routes = [
{ path: '/content/:aid', component: Content },
]
2、在列表页NewsList绑定动态数据
<router-link :to="'/content/'+index">{{index}}---{{item}}</router-link>
3、在对应content页面获取传值
this.$route.params //获取动态路由的值
get传值
1、配置路由,非动态,main.js
const routes = [
{ path: '/pcontent/', component: PContent },
]
2、在列表页NewsList绑定动态数据
<router-link :to="'/pcontent?pid=' + index">{{index}}--{{item}}</router-link>
3、在对应content页面获取传值
console.log(this.$route.query) //获取get传值