Vue router 参数传递

接收参数

let router =  new VRouter({
  mode: 'history',
  routes: [
    {
      path: '/apple/:color',   //接收参数
      name: 'apple',
      component: Apple
    },{
      path:'/banana/:color/detail/:type',
      name: 'banana',
      component: Banana
    }
  ]
})

读取参数

methods:{
    getParam(){
        console.log(this.$route.params)
    }
}

<div>{{ $route.params.color }}</div>
发布了38 篇原创文章 · 获赞 5 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/weixin_39423672/article/details/78802342
今日推荐