vue去路由的#以及刷新404

首先,去#直接在路由加:
export default new Router({
  mode: 'history',  //去掉url中的#
  routes: [
    {
      path: '/',
      name: 'Index',
      component: Index
    },
    {
      path: '/stars',
      name: 'Stars',
      component: resolve => require(['../components/page/Stars.vue'], resolve)
    },
然后在nginx里配置:
location / {
  try_files $uri $uri/ /index.html;
}

try_files相关内容:https://www.hi-linux.com/posts/53878.html

发布了64 篇原创文章 · 获赞 26 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/moliyiran/article/details/104115508