猿问

vue路由中的mode是什么意思?

export function createRouter () {

  return new Router({

    mode: 'history',

    scrollBehavior: () => ({ y: 0 }),

    routes

  })

}

看文档没看懂?自己测试,去掉mode根路由后面会自动添加 #/ 
eg: http://localhost:8080/#/              http://localhost:8080/#/index
请问这是为什么,还有这个scrollBehavior是什么意思。。。。

MMTTMM
浏览 1872回答 4
4回答

慕慕森

HTML5 History 模式,猜测你应该是看懂了,但是测试不对。history模式不会带上#,至于错哪就目前的代码来看并不知道。切换路由时希望定位到哪个位置const router = new VueRouter({   routes: [...],   scrollBehavior (to, from, savedPosition) {    // return 期望滚动到哪个的位置   } })

慕的地8271018

不要没有任何基础知识就去上手框架,不要没有任何基础知识就去上手框架,不要没有任何基础知识就去上手框架。建议自己 Google:「前端路由」

ABOUTYOU

还是可以直接百度的,文档有些写得比较深奥,大概意思就是,去掉url后面的#并将页面顶部至为可视区域
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答