【问题标题】:Getting Inertia.js and Xampp to work together让 Inertia.js 和 Xampp 协同工作
【发布时间】: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


【解决方案1】:

所以,由于我对我想做的事情还不是很远,所以我决定停止,卸载 XAMPP,安装 Laragon,然后从那里开始。我只是按照文档进行操作,现在一切似乎都正常了。我的直觉告诉我 XAMPP 不起作用,它与必须手动配置 httpd-vhosts.conf 和 etc/hosts 文件有关。

【讨论】:

    猜你喜欢
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-28
    • 2011-09-25
    • 2016-03-09
    • 1970-01-01
    相关资源
    最近更新 更多