【发布时间】:2019-07-19 13:25:40
【问题描述】:
我尝试使用 Laravel、Vue 和 Inertia 建立一个项目。我正在使用 xampp 在 Windows 上进行开发。
我已使用以下内容配置 C:/xampp/apache/conf/extra/httpd-vhosts.conf:
<VirtualHost inertia-example.test:80>
DocumentRoot "c:/xampp/htdocs/inertia-example/public"
<Directory "c:/xampp/htdocs/inertia-example/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
我还在 C:/Windows/System32/drivers/etc/hosts 中添加了一个条目
当我转到惯性示例.test 时,我看到的只是一个带有文本“欢迎使用 Laravel!”的 h1 标签,这肯定不是 Welcome.vue 中的内容。
有人有什么想法吗?
如果有帮助,这里是指向 github 的链接 (https://github.com/inertiajs/inertia-laravel)。
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">
<link href="{{ mix('/css/app.css') }}" rel="stylesheet">
<script src="{{ mix('/js/app.js') }}" defer></script>
</head>
<body>
@inertia
</body>
</html>
路由文件,特别是 web.php,是:
<?php
use Inertia\Inertia;
/*
|--------------------------------------------------------------------------
| 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('welcome');
return Inertia::render('Welcome');
});
Welcome.vue 如下:
<template>
<div>
This is the Welcome page!
</div>
</template>
【问题讨论】:
-
你配置好你的路由了吗?你是否更新了你的
app.blade.php,如repo中的@inertia? -
两个问题都是。
-
你能出示你的
routes/web.php和app.blade.php吗? -
我已根据要求更新了问题。
-
谢谢。您是否还为 Inertia 安装了 Vue adapter?如果是这样,您还可以在问题中添加
Welcome.vue吗?
标签: laravel vue.js xampp inertiajs