2017-11-02 22 views
1

ノードにvue-routerがインストールされています。 これは私のプロジェクトのURLですhttp://localhost/UserApp/publicです。Vue-routerが正しく動作していません

私が使用した2つのルートルートは、/home &​​ ですので、私はホームルートをクリックします。私はhttp://localhost/home にリダイレクトされますが、それはhttp://localhost/UserApp/public/homeである必要があります。 ページをリロードするとき。それはobject not foundエラーをスローします。 http://localhost/homeのようなルートがないため。 どうすれば問題を解決できますか?

app.js

import Vue from 'vue' 
import VueRouter from 'vue-router' 
Vue.use(VueRouter) 

const routes = [ 
    { path: '/home', component: Home }, 
    { path: '/about', component: About } 
] 

const router = new VueRouter({ 
    mode : 'history', 
    routes // short for `routes: routes` 
}) 

web.php

Route::get('/{name}',function(){ 
    return redirect('/'); 
})->where('name','[A-Za-z]+'); 

Myheader.vue

<router-link to="/home" class="navbar-item">Home</router-link> 
<router-link to="/about" class="navbar-item">About</router-link> 

答えて

0

あなたはvue-にベースアプリケーションのパスを変更する必要がありますルータの設定、

DOCS:

Route::get('/{any}', function(){ 
    return view('index'); 
})->where('any', '.*'); 
https://router.vuejs.org/en/api/options.html#base

ベースは、私がしようと、ルーティングオプションとして

を伝えることができるものから/UserApp/publicする必要があります