跨页面锚点就失效,而且vue一启动页面高度就是之前的而不是顶部
好像是监听滚动轴事件自动执行了
新版的谷歌和火狐之类的会自动设置到上次滚动到的位置,这个浏览器的行为,没法控制,也会同时触发绑定的scroll事件。
你要定位到对应锚点可以试试在在你绑定的scroll事件中执行下面的代码重新定位
var hash = location.hash.substring(1);
if (hash) {
var el = document.querySelector('#' + hash);
if (!el) el = document.querySelector('a[name="' + hash + '"]');
if (el) window.scrollTo(0,el.offsetTop)
}