情景: vue-cli脚手架 vue-router配置路径 ,npm run dev后 点击路由 发现url中有#, 从而不能成功跳转至具体页面
vue中localhost:8080地址栏的显示有两种模式:
- 第一种是hash(默认),即mode: hash ,该模式地址栏会默认有#号。
- 第二种是history,即mode: history ,该模式直接用url。
在rouer下面的index.js中书写:
export default new Router({
mode: history , // 即可去掉#
routes: [
{
path: / ,
name: home ,
component: home
},
{
path: /classify ,
name: classify ,
component: classify
}
]
})
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...


