让我们看看vue路由传值方式

169 阅读1分钟

IMG_0288(20210308-192140).JPG

相信我们在实现路由跳转种都有接触到路径传值问题,那么接下来介绍以下几种熟悉的传值方式

1.显式

eg:http://localhost:8080/about?a=1 1.1传值: this.$router.push({ path:'/about', query:{a:1} })

1.2接收传过来的值 this.$route.query.a

2.隐式

2.1传值: eg:http://localhost:8080/about this.$router.push({ name:'About', params:{a:1} }) 2.2接收: this.$route.params.a

3 修改路由导航

this.$route.query.num

欢迎大家来一起学习交流,一起成长!