我已安装
Laravel 8
和
缺乏活力
具有
卵黄
和
反应
,遵循文档
serve side
和
client side
我的要求是
Laravel 8
和
缺乏活力
具有
Reactjs
使用
Vite
。
我面临的问题是
/resources/views/app.blade.php
。它没有按如下方式呈现原始输出
web.php
use Inertia\Inertia;
Route::get('/', function () {
return Inertia::render('Homepage');
});
app.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
@viteReactRefresh
@vite(['resources/css/app.css', 'resources/js/app.jsx'])
@inertiaHead
</head>
<body>
@inertia
</body>
</html>
vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
react(),
laravel({
input: [
'resources/css/app.css',
'resources/js/app.jsx',
],
refresh: true,
}),
],
});
package.json
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build && vite build --ssr"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.0.4",
"alpinejs": "^3.4.2",
"autoprefixer": "^10.4.2",
"axios": "^0.21",
"laravel-mix": "^6.0.49",
"laravel-vite-plugin": "^0.4.0",
"lodash": "^4.17.19",
"postcss": "^8.4.6",
"resolve-url-loader": "^5.0.0",
"sass": "^1.64.2",
"sass-loader": "^12.6.0",
"tailwindcss": "^3.1.0"
},
"dependencies": {
"@inertiajs/react": "^1.0.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"vite": "^4.4.9"
}
}