我正在学习如何使用livewire和laravel,我尝试通过一个输入框绑定一些数据 我编写了以下代码:
home.blade.php:
<html>
<head>
<title>Home</title>
@livewireStyles
</head>
<body>
@livewire("hello-world")
@livewireScripts
</body>
</html>
hello-world.blade.php:
<div>
<input wire:model="nome" type="text">
<br>
Hello {{ $nome }}
</div>
HelloWorld.php:
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class HelloWorld extends Component
{
public $nome = 'Name';
public function render()
{
return view('livewire.hello-world');
}
}
当前正在运行 Apache 2.4。 但是,如果我在加载页面时打开浏览器控制台,则会出现以下错误:
(index):29 GET http://localhost/livewire/livewire.js?id=c1db26b321e994f87254 net :: ERR_ABORTED 404(未找到)
(index):35 Uncaught ReferenceError:Livewire未定义 at(index):35
我遵循官方文档和屏幕录像,尝试逐步遵循所有说明,但仍然无法解决问题。 也许我在安装过程中做错了什么,但是我认为不是这样,因为我只输入了:
composer require livewire/livewire
所以应该没问题。 有什么提示吗?
GitHub repo:learningLaravel
http://localhost
吗? - Clément Baconnier