我在網上看到,url中的hashtag是由于沒有在vue路由器中使用history造成的。
目前,我正在做一個大專案,重新開始并在終端中選擇歷史模式會浪費時間。
所以我想問一下vue專案已經生成的時候,是否可以使用switch to history mode?
這是我的網址: http://localhost:8081/#/
uj5u.com熱心網友回復:
Vue 路由器的默認模式是散列模式。您不需要再次安裝整個應用程式,只需在您定義了 vue 路由器的應用程式中將模式更新為歷史模式,如下所示:
對于路由器 v3:
const router = new VueRouter({
mode: 'history'
})
對于路由器 v4:
const router = VueRouter.createRouter({
history: VueRouter.createWebHashHistory(),
})
供參考:https : //next.router.vuejs.org/guide/#javascript
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/373156.html
上一篇:有重名時洗掉URL搜索引數?
