试过了一样的,
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
routes: [
{path:'/',name:"Home",component:()=>import('../views/Home.vue')},
{path:'/city',name:"list",component:()=>import('../city/City.vue')},
{path:'/detail/:id',name:"detail",component:()=>import('../components/detail/detail.vue')},
],
mode:"history",
base:process.env.BASE_URL,
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return {
x: 0,
y: 0
}
}
}
})