라라벨/Vue(laravle)
404페이지 설정하기
땀모
2020. 1. 13. 21:30
정의되지 않은 페이지는 404페이지를 사용자 정의하는 방법이다.
1. resources/js/components/Notfound.vue 파일을 만들어준다.
2. resources/js/routes.js
1 | import Notfound from './components/Notfound'; | cs |
1 2 3 4 5 6 | { path: '*', component: Notfound }, | cs |
전체
정의되지 않은 패스는 /components/Notfound 로 가게 설정하는 것이다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import Logo from './components/Logo'; import LogoSymbol from './components/LogoSymbol'; import Colors from './components/Colors'; import Notfound from './components/Notfound'; export default{ mode : 'history', linkActiveClass: 'font-bold text-blue-500', routes:[ { path: '*', component: Notfound }, { path: '/', component: Logo }, { path: '/logo-symbol', component: LogoSymbol }, { path: '/colors', component: Colors }, ] }; | cs |
3.routes/web.php 파일
1 2 3 4 | Route::get('/{any?}', function () { return view('app'); })->where('any','.*'); | cs |