Добрый день! помогите плиз, настраивал роутер и сайт перестал отвечать, выдает такую ошибку laravel + Vue IndexController.php PHP: <?php namespace App\Http\Controllers; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; use Illuminate\Http\Request; class IndexController extends BaseController { public function __invoke() { return view( 'admin'); } }
сорян, сразу не подумал. router.js PHP: import Vue from 'vue'; import VueRouter from "vue-router"; import admin from "./panel/admin"; Vue.use(VueRouter) export default new VueRouter( { mode: 'history', routes: [ { path:'/admin', component: admin } ] }) Web.php PHP: <?php use Illuminate\Support\Facades\Route; /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */ Route::get('/', function () { return view('index'); }); Auth::routes(); Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); Route::get('/{page}', 'IndexController')->where('page', '.*');
Попробуйте добавить новый метод в контроллер HomeController::show($page) PHP: public function show($page) { return $page; } в web.php PHP: Route::get('/{page}', [App\Http\Controllers\HomeController::class, 'show'])->where('page', '.*');
Это почти правильно. Для invoke-контроллеров не нужен массив. https://laravel.com/docs/9.x/controllers#single-action-controllers А какую связь vuejs имеет с серверным роутингом?