<router-link :to="{name:\'home\'}">
<router-link :to="{path:\'/home\'}">
<router-link :to="{name:\'home\', params: {id:1}}">
// params傳參數(shù) (類似post)
// 路由配置 path: "/home/:id" 或者 path: "/home:id"
// 不配置path ,第一次可請求,刷新頁面id會消失
// 配置path,刷新頁面id會保留
// html 取參 $route.params.id
// script 取參 this.$route.params.id
<router-link :to="{name:\'home\', query: {id:1}}">
// query傳參數(shù) (類似get,url后面會顯示參數(shù))
// 路由可不配置
// html 取參 $route.query.id
// script 取參 this.$route.query.id
1、this.$router.push() 路由跳轉
this.$router.back()
this.$router.go()
this.$router.push({name:\'home\',query: {id:\'1\'}})
this.$router.push({path:\'/home\',query: {id:\'1\'}})
// html 取參 $route.query.id
// script 取參 this.$route.query.id
this.$router.push({name:\'home\',params: {id:\'1\'}}) // 只能用 name
// 路由配置 path: "/home/:id" 或者 path: "/home:id" ,
// 不配置path ,第一次可請求,刷新頁面id會消失
// 配置path,刷新頁面id會保留
// html 取參 $route.params.id
// script 取參 this.$route.params.id
3. this.$router.replace() (用法同上,push)