You are viewing a single comment's thread from:

RE: Vue.js实战笔记

in #starnote4 years ago

刷新页面的问题

//router.js
const router = new VueRouter({
  mode: 'hash',
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})
export default router

历史模式(history)的路径比较好看,比如:https://steemjiang.com/hotarticle/6725b
但是,会碰到刷新就404的错误!这个可以在nginx的配置中设置:
location / {
        root   /home/dist-steemjiang;       
        index  index.html index.htm;        
     if (!-e $request_filename) {   #history模式的设置   
         rewrite ^/(.*) /index.html last;
          break;
        }
    }

哈希模式(hash), 路径中有'#',比如:https://starnote.github.io/#/starnote/7s4b6 
它无需任何额外的配置,所以,在github中可以直接使用!