2017-04-25 9 views
4

私はdevueモードで正常に動作するvue cliでプロジェクトを開発しました。しかし、私はそれを構築する。ルート( '/'、コンポーネント)によってロードされたコンポーネントがなくてもすべてうまくいく。 いただきました間違った私のコードでは、私はあなたが チェックhttps://router.vuejs.org/en/essentials/history-mode.htmlvueルータがvue cliビルドで動作していません

nginxの仕事に履歴モードのための書き換えを処理する必要があると思います

import Vue from 'vue' 
import App from './App' 
import router from './router/index' 

Vue.config.productionTip = false 
new Vue({ 
    router, 
    template: '<App/>', 
    components: { App } 
}).$mount('#app') 

import Vue from 'vue' 
    import Router from 'vue-router' 
    import Home from '@/components/Home.vue' 
    import List from '@/components/List.vue' 
    const router = new Router({ 
    mode: 'history', 
    routes: [ 
    { 
     path: '/', 
     component: Home 
    }, 
    { 
     path: '/buy-n-sell/:category', 
     component: List, 
     children: [ 
     { 
      path: '', 
      component: catLists 
     }, 
     { 
      path: 'location/:city', 
      component: cityLists, 
      name: 'citypostList' 
     }, 
     { 
      path: 'subcategory/:subcat', 
      component: subcatList, 
      name: 'subcatpostList' 
     }, 
     { 
      path: 'subcategory/:subcat/:city', 
      component: subcatCityList, 
      name: 'subcatecityList' 
     } 
     ] 
    } 
    ] 
}) 
export default router 

答えて

1

location/{ 
    try_files $uri $uri/ /index.html; 
} 

Apacheを(/dist/.htaccessを作成する)

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.html$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.html [L] 
</IfModule> 
関連する問題