import Vue from 'vue' import VueRouter from 'vue-router' import withmind from '../views/withmind/index.vue' Vue.use(VueRouter) const routes = [ { path: '/', redirect: "/withmind" }, { path: '/withmind', name: 'withmind', component: withmind } ] const router = new VueRouter({ mode: 'hash', base: process.env.BASE_URL, routes, // 每次进入路由(包括刷新页面)都滚到顶部 scrollBehavior(to, from, savedPosition) { if (savedPosition) { // 浏览器前进/后退 → 恢复原位置 return savedPosition } // 否则(包括刷新)滚到顶部 return { top: 0 } } }) export default router