vue-router页面跳转传递参数
需求:A页面携带参数跳转至B页面,B页面获取参数且根据参数内容进行不同页面的展示。
A页面:
more(name) { this.$router.push({path:'./classification',query:{name: name}}) },
B页面:
mounted() { this.activeName = parseInt(this.$route.query.name) },
注:
原本想直接给data里的activeName使用$route赋值,但其实这样是获取不到的,activeName为undefined,所以改用mounted方法将传递来的参数赋值给activeName。

浙公网安备 33010602011771号