this.$router.push({path:'/xxx',query:{id:1}});//相似get傳參,經過URL傳遞參數
this.$route.query.id
//因爲動態路由也是傳遞params的,因此在 this.$router.push() 方法中 path不能和params一塊兒使用,不然params將無效。
須要用name來指定頁面。
this.$router.push({name:'page2',params:{id:1}});//相似post傳參
this.$route.params.id
watch: {
'$route'(to, from){ //在這裏從新刷新一下 this.getParams(); } }