我正在学习如何使用 livewire 和 laravel,我试图通过输入绑定一些数据,我编写了这段代码:
home.blade.php:
<html>
<head>
<title>Home</title>
@livewireStyles
</head>
<body>
@livewire("hello-world")
@livewireScripts
</body>
</html>
你好-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 上运行但是如果我在加载页面时打开浏览器控制台,我会得到:
(索引):29 GET http://localhost/livewire/livewire.js?id=c1db26b321e994f87254 net::ERR_ABORTED 404(未找到)
(index):35 Uncaught ReferenceError: Livewire is not defined at (index):35
我正在关注官方文档和截屏视频,我尝试逐步按照所有说明进行操作,但它也不起作用。也许我在安装过程中做错了什么,但我不这么认为,因为我刚刚打了:
作曲家需要 livewire/livewire
所以应该没问题。有什么线索吗?
GitHub 仓库:learningLaravel