在vue中的錨鏈接和普通的html不同,關於vue中的錨鏈接可以參考vue 中的 scrollBehavior 滾動行為。
在router.js中
//創建 router 實例 const router = new VueRouter({ routes, mode: ‘history‘, scrollBehavior(to, from, savedPosition) { if (to.hash) { return { selector: to.hash } } } }) export default router;
在vue中 點擊跳轉的位置 使用<a>鏈接包起來
<div>
    <a href="#populationInformation">人口畫像</a>
</div>
<div>
    <a href="#peopleCounting">人流統計</a>
</div>
<div>
    <a href="#trafficAnalysis">交通分析</a>
</div> 
        在需要跳轉到的位置
<div id=‘populationInformation ‘> 人口畫像跳轉到此</div> <div id=‘peopleCounting‘> 人流統計跳轉到此 </div> <div id=‘trafficAnalysis ‘>交通分析跳轉到此 </div>
 
         要保證<a>標簽的 href 的地址要和下面id的值是相同的才可以完成相應的跳轉,至於在router中的配置也是必須的。 
        
 
         
         
        