2017-11-02 8 views
1

node와 함께 vue-router를 설치했습니다. 내 프로젝트 URL은 http://localhost/UserApp/public입니다. 내가 홈 경로를 클릭하면Vue-router가 올바르게 작동하지 않습니다.

그리고 내가 사용하는 두 VUE 노선 /home & /about 그래서입니다. 나를 http://localhost/home 으로 리디렉션하지만 http://localhost/UserApp/public/home이어야합니다. 그래서 페이지를 새로 고침 할 때. object not found 오류가 발생합니다. http://localhost/home과 같은 경로가 없기 때문입니다. 어떻게 문제를 해결할 수 있습니까?

당신은 vue-에서 기본 응용 프로그램의 경로를 변경해야

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

을 app.js 라우터 구성,

DOCS : 내가 라우팅 옵션으로

을 말할 수있는 것과 /UserApp/public을해야 https://router.vuejs.org/en/api/options.html#base

기본, 시도 :

Route::get('/{any}', function(){ 
    return view('index'); 
})->where('any', '.*');