我正在学习如何使用 livewire 和 laravel,我试图通过输入绑定(bind)一些数据
我写了这段代码:
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>
Hello World .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 (Not Found)
(index):35 Uncaught ReferenceError: Livewire is not defined at (index):35
我正在关注官方文档和截屏视频,我试图一步一步地按照所有说明进行操作,但它也不起作用。
也许我在安装过程中做错了什么,但我不这么认为,因为我刚刚打了:
composer require livewire/livewire
所以应该没问题。
有什么线索吗?
GitHub 存储库:learningLaravel
最佳答案
你可以试试这个:
运行:php artisan livewire:publish
然后打开配置/livewire.php
改 'asset_url' => null
至 'asset_url' => 'http://localhost'
关于php - Livewire 404:获取 http://localhost/livewire/livewire.js net::ERR_ABORTED 404(未找到),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63842545/