本文共 677 字,大约阅读时间需要 2 分钟。
页面访问地址
首页: 用户中心 :路由配置js 设置 mode 为history ,这样会去掉#号 和正常的路由地址一样
export default new Router({ mode: 'history', routes: [ { path: '/world', // 注意 路由的path 需要和页面的地址保持一致,即域名后的二级目录都得一样,否则会报错 name: 'index', component: index }, { path: '/world/user', name: 'user', component: user }, { path: '*', redirect: { name: 'index'} } ]})
vue官方文档推荐
例如:项目区分pc 和 h5 项目,且两个项目为独立的
主目录为: 层级:pc: /hello-pc/ h5: /hello-h5/ 用户访问链接:pc :用户访问链接:h5 :
nginx 这时候可以这么配置:
location /hello-pc/ { try_files $uri $uri/ /hello-pc/index.html}location /hello-h5/ { try_files $uri $uri/ /hello-h5/index.html}