2016-06-01 114 views
1

我使用VueRouterHTML5歷史記錄模式。我使用引導程序'導航'與錨標籤。當用戶點擊任何錨標籤時,Vue應用程序將重新加載。 HTML如何設置vue.js忽略錨標籤?

<a href="#tab_contacts" data-toggle="tab">Contacts</a> 

例子是通過路由器忽略錨標記任何方法嗎?

+0

路由器已經忽略了錨標記。這個問題可能存在於別的地方。 –

回答

1

可以使用canDeactivate hook從重載頁面停止VUE,例如:

route: { 
    //called before page deactivate 
    canDeactivate: function(transition) { 
     if(...){//check if the route should be ignored 

      transition.abort(); //this will stop vue-router from reloading the page 
     } 
    } 
} 
+0

Kaicui,你的解決方案不適用於錨標籤。它僅適用於vue鏈接。 – rnofenko