Vue router 参数传递

来源:互联网 发布:树莓派java服务器 编辑:程序博客网 时间:2024/06/09 16:14

接收参数

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>