使用router-link傳參:
第一種:
路徑:http://localhost:8080/goodListP?id=2
跳轉的頁面獲取參數:
this.$route.query.id
第二種:
路徑:http://localhost:8080/goodListP/2
路由配置:
跳轉的頁面獲取參數:
this.$route.params.id;
問題:使用router-link跳轉到頁面時,頁面要F5刷新一下才能獲取到數據
解決方法如下:
第一種:
加上一個點擊事件進行刷新頁面
@click.native:事件后面要添加.native,不然添加的事件不起作用,具體原因應該是router-link為了阻止a標簽的默認跳轉事件
第二種:
不給router-link添加點擊事件,在跳轉到的頁面中加上以下代碼: