vue路由器和锚点

时间:2018-02-23 11:20:19

标签: vue.js vuejs2 vue-router

我已设置路由器以接受锚标记

const router = new VueRouter({
        mode: 'history',
        scrollBehavior: function(to, from, savedPosition) {
            if (to.hash) {
                return {selector: to.hash}
            } else {
                return {x: 0, y: 0}
            }
        },
        routes: routes,
    });

如果我点击刷新

,这很好
http://localhost/mypage#anchorlocation

我得到了WSOD,对主页的反应很好。我怎么能抓到这个?

1 个答案:

答案 0 :(得分:0)

这与vue-router无关,因为只要您使用mode: 'history'

,它就是服务器配置

使用您偏好的服务器配置查看https://router.vuejs.org/en/essentials/history-mode.html