在router→index.js文件中加入 scrollBehavior(to, from, savedPosition) { return { x: 0, y: 0 }; }
如下: export default new Router({ mode: 'history', // 使用 HTML5 History 模式 routes: [], // 页面跳转后滚动条自动置顶 ** scrollBehavior(to, from, savedPosition) { return { x: 0, y: 0 }; }** });