vue动态路由传值以及get传值

1.动态路由传值

  1.配置路由处

  { path: '/content/:id', component: Content }, // 动态路由
  
  2.对应页面传值
  <router-link :to="/content/+item">{{item}}</router-link>
 
  3.对应页面接值
  this.$route.params.id;

main.js

home

content

2.get传值方法

无需配置路由

{ path: '/content/:id', component: Content }, // 动态路由
  
  1.对应页面传值
  <router-link :to="'/content?id='+item">{{item}}</router-link>
 
  2.对应页面接值
  this.$route.query.id;

猜你喜欢

转载自www.cnblogs.com/v616/p/11263968.html