
export default new Router({
mode: 'history', // history 去掉url中的# 、hash 包含#号
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
本文介绍了如何在React应用中使用Router组件,关注点在于设置history模式以移除URL中的#号,并定义scrollBehavior来控制页面滚动。路由配置详细展示了constantRoutes的使用。

export default new Router({
mode: 'history', // history 去掉url中的# 、hash 包含#号
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
5130
2374

被折叠的 条评论
为什么被折叠?