vue锚点设置
路由设置----(针对history模式)
const router = new VueRouter({
mode: 'history',
/** 兼容 #id 锚点定位 */
scrollBehavior (to, from, savedPosition) {
if (to.hash) {
return {
selector: to.hash
}
}
},
});
使用场景
div 加上id属性,比如
<div id="a123"></>
定位: http://itshowing.com/#a123
ok!