Nan*_*ncy 5 inertiajs laravel vue.js
我正在尝试设置 Inertia 以在我的 Laravel 项目中使用,但它给了我错误?我的错误在哪里?
我用这个命令安装了 Inertia
composer require inertiajs/inertia-laravel
按照 github 页面上的说明进行操作,并将其添加@inertia到我的 app.blade.php 中,如下所示:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
<link rel="icon" type="image/jpg" href="{{asset("/image/logo2.png")}}">
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
@inertia
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在我的登录控制器中
public function showLoginForm()
{
return Inertia::render('Auth/Login');
}
Run Code Online (Sandbox Code Playgroud)
在我的routes/web.php中
Auth::routes();
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
突出显示的行是@inertia这样显示的
<div id="app" data-page="<?php echo e(json_encode($page)); ?>"></div>
我究竟做错了什么?
@inertiaBlade 指令正在工作但未呈现,因为您需要安装前端适配器
npm install @inertiajs/inertia @inertiajs/inertia-vue\nRun Code Online (Sandbox Code Playgroud)\n设置在webpack.mix.js\xc2\xa0
npm install @inertiajs/inertia @inertiajs/inertia-vue\nRun Code Online (Sandbox Code Playgroud)\n并在Vue中初始化它resources/js/app.js
const mix = require(\'laravel-mix\')\nconst path = require(\'path\')\n\nmix.js(\'resources/js/app.js\', \'public/js\')\n .webpackConfig({\n output: { chunkFilename: \'js/[name].js?id=[chunkhash]\' },\n resolve: {\n alias: {\n vue$: \'vue/dist/vue.runtime.esm.js\',\n \'@\': path.resolve(\'resources/js\'),\n },\n },\n })\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
17236 次 |
| 最近记录: |