我正在尝试在 laravel react.js 组合中建立 axios 示例。我按照 composer create-project --prefer-dist laravel/laravel react-laravel-basic-8 命令配置了我的项目。php artisan 预设 react npm install npm audit fix --force npm install axios npm run dev php artisan serve。我的 web.php 文件是
Route::get('/', function () {
return view('welcome');
});
Route::get('add-a-student',function()
{
return view('add_student');
});
Route::get('/testing/','Admin@testing');
Run Code Online (Sandbox Code Playgroud)
我的控制器 Admin.php 是
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Admin extends Controller
{
public function testing()
{
echo "hello alert";
}
}
Run Code Online (Sandbox Code Playgroud)
我的观点 add_student.blade.php 是
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<title>React axios</title>
<link …Run Code Online (Sandbox Code Playgroud)