Laracasts 教程问题

编辑/解决方案:我似乎找到了罪魁祸首。我使用的是 Visual Studio 的实时服务器扩展,结果发现它不像 artisan 那样为 Laravel 提供服务。解决方案是使用 artisan,不过我会看看我是否可以让 Live 服务器的自动重新加载功能正常运行。

我正在做的 Laracasts 教程似乎遇到了一些问题。 本来我觉得这和我在 Windows 上工作有关,但编码应该不会有太大变化。

首先,我的“a href”仅在使用完整的刀片名称时才有效,而不仅仅是速记“post”,如下所示:

<h1><a href="post.blade.php">My First Post</a></h1>

第二个根文件 'a href="/"' 不起作用,我收到错误:

"The requested resource / was not found on this server."

它只能通过使用完整的刀片名称才能再次起作用,如下所示:

<a href="posts.blade.php">Go Back</a>

这是正常行为吗?

现在尝试解析“post”变量时出现错误:

"Notice: Undefined variable: post in C:\laragon\www\blog\resources\views\post.blade.php on line 10"

我的代码如下 web.php

Route::get('/',function () {
    //return 'hello';
    return view('posts');
});

Route::get('post',function () {
    
    return view('post',[
        'post' => '<h1>Hello World</h1>'
    ]);
      
});

post.blade.php

<!doctype html>

<title>My Blog</title>
<link rel="stylesheet" href="\public\app.css">

<body>
    <article>
    <?=$post;?>
    </article>

    <a href="posts.blade.php">Go Back</a>
</body>

我们将不胜感激,因为在解决这些问题之前我无法继续。

ning61 回答:Laracasts 教程问题

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1837.html

大家都在问