vue-router 路由模式


  vue-router 的路由模式有三種: hash、history、abstract;

    hash:瀏覽器環境,使用 URL hash 值來做路由;支持所有瀏覽器,包括不支持 HTML5 History Api 的瀏覽器;

    history:依賴 HTML5 History API 和 服務器配置;

    abstract:支持所有 javaScript 運行環境,如 node.js 服務器;如果發現沒有瀏覽器的 API,路由會自動強制進入這個模式;  

 

  vue 源碼:

switch (mode) {
    case  'history' : 
       this.history = new HTML5HIstory(this, option.base)
       break
    case   'hash' : 
       this.history = new HashHistory(this, option.base,  this.fallback)
       break
    case 'abstract' : 
       this.history = new AbstractHistory(this, options.base)
       break
    default : 
       if (process.env.NODE_ENV !== 'production') {
           assert(false,  `invalid mode : ${mode}`)
       }
}         

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM