[英]No reload navigation with anchor tags
我正在嘗試構建一個簡單的 HTML、CSS JS 站點,並且我正在使用錨標記在某些路線之間導航。 我想使用無刷新頁面導航,這意味着它會更改路線並呈現該路線的內容,但在更改路線時不會重新加載。 我怎樣才能做到這一點? 例如:如果你 go 到 nextjs 的文檔,你會注意到它只是改變了路線但沒有重新加載頁面
這可以通過歷史 api 完成
var data = e.target.getAttribute('data-name'),
url = data + ".html";
history.pushState(null, null, url);
// here we can fix the current classes
// and update text with the data variable
// and make an Ajax request for the .content element
// finally we can manually update the document’s title
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.