javascript - vuerouter2使用router.go一直在刷新
問題描述
代碼如下
沒有最后一行的時(shí)候正常,只是想進(jìn)來的時(shí)候,默認(rèn)在goods頁面,但是頁面一直在跳轉(zhuǎn),不知道是什么問題。看vuerouter的文檔沒有發(fā)現(xiàn),想默認(rèn)選中一個(gè)該用什么api
問題解答
回答1:{ path: ’/’, component: Goods},
回答2:重定向
http://router.vuejs.org/zh-cn...
回答3:routes中增加一個(gè)當(dāng)前默認(rèn)頁對象:
const routes = [{ path: ’/’, component: Goods},{ path: ’/goods’, component: Goods},{ path: ’/seller’, component: Seller},{ path: ’/ratings’, component: Ratings}];回答4:
vue-router 中的 router的設(shè)計(jì)模式是參考了瀏覽器的window.history相關(guān)API
同history.go, router.go接受的參數(shù)應(yīng)該為Number, 例如:
// 上一頁history.go(-1)router.go(-1)
而你應(yīng)該使用的是 router.push
相關(guān)文章:
1. 安全性測試 - nodejs中如何防m(xù)ySQL注入2. javascript - 關(guān)于apply()與call()的問題3. html - eclipse 標(biāo)簽錯(cuò)誤4. python 利用subprocess庫調(diào)用mplayer時(shí)發(fā)生錯(cuò)誤5. python - Pycharm的Debug用不了6. datetime - Python如何獲取當(dāng)前時(shí)間7. 請問PHPstudy中的數(shù)據(jù)庫如何創(chuàng)建索引8. python - pycharm 自動刪除行尾空格9. python文檔怎么查看?10. javascript - nginx反向代理靜態(tài)資源403錯(cuò)誤?
