Laravel 8 - wire:model 输入无效
Laravel 8 - wire:model on input not working
我正在尝试使用 livewire,但无法正常工作。
我有一条路线:
Route::middleware(['auth:sanctum', 'verified'])
->get('/nuevoturno', NuevoTurno::class)
->name('nuevoturno');
NuevoTurno.php 包含:
namespace App\Http\Livewire;
use App\Models\FormatoTurno;
use Livewire\Component;
class NuevoTurno extends Component
{
public $qFecha = '2020-11-17';
public function render()
{
return view('livewire.nuevo-turno',[
'formatoTurno' => FormatoTurno::First()
]);
}
}
livewire 视图:
@section('header', 'Nuevo Turno')
@section('content')
{{ $qFecha }}
<input type="text" value="{{ $qFecha }}">
<div>
<br>
{{-- A good traveler has no fixed plans and is not intent upon arriving. --}}
{{ $formatoTurno->Distancia_Entre_Turnos }}
{{ $formatoTurno->Hora_Inicio }}
{{ $formatoTurno->Hora_Fin }}
</div>
@endsection
{{ $qFecha }} 正在显示,但输入未填写
所以..发生了什么事?
编辑:
我将 @section('content') 更改为,并在 app.blade.php 中将 @yield('content') 更改为 {{ $slot }}
现在它出现了:
< wire:id="BCEos1ECXtGL114CYnTn" wire:initial-data="{"fingerprint":{"id":"BCEos1ECXtGL114CYnTn","name":"nuevo-turno","locale":"es"},"effects":{"listeners":[]},"serverMemo":{"children":[],"errors":[],"htmlHash":"850cd1b2","data":{"qFecha":"2020-11-17"},"dataMeta":[],"checksum":"3cb32d8a817d51f7ff71a9ebeb184da10fb421dc1eb00e1ddd53a4ab30dcefb7"}}"!doctype html>
[解决方案]
我将 app.blade 格式从 @yield()
更改为 {{ $slot }}
。
还更改了 livewire 组件 nuevo-turno.blade:
<x-slot name="header">
Nuevo Turno
</x-slot>
<div>
{{ $qFecha }}
<input type="text" value="{{ $qFecha }}">
<div>
<br>
{{-- A good traveler has no fixed plans and is not intent upon arriving. --}}
{{ $formatoTurno->Distancia_Entre_Turnos }}
{{ $formatoTurno->Hora_Inicio }}
{{ $formatoTurno->Hora_Fin }}
</div>
</div>
现在可以了。
谢谢大家的回答!
我正在尝试使用 livewire,但无法正常工作。
我有一条路线:
Route::middleware(['auth:sanctum', 'verified'])
->get('/nuevoturno', NuevoTurno::class)
->name('nuevoturno');
NuevoTurno.php 包含:
namespace App\Http\Livewire;
use App\Models\FormatoTurno;
use Livewire\Component;
class NuevoTurno extends Component
{
public $qFecha = '2020-11-17';
public function render()
{
return view('livewire.nuevo-turno',[
'formatoTurno' => FormatoTurno::First()
]);
}
}
livewire 视图:
@section('header', 'Nuevo Turno')
@section('content')
{{ $qFecha }}
<input type="text" value="{{ $qFecha }}">
<div>
<br>
{{-- A good traveler has no fixed plans and is not intent upon arriving. --}}
{{ $formatoTurno->Distancia_Entre_Turnos }}
{{ $formatoTurno->Hora_Inicio }}
{{ $formatoTurno->Hora_Fin }}
</div>
@endsection
{{ $qFecha }} 正在显示,但输入未填写
所以..发生了什么事?
编辑: 我将 @section('content') 更改为,并在 app.blade.php 中将 @yield('content') 更改为 {{ $slot }} 现在它出现了:
< wire:id="BCEos1ECXtGL114CYnTn" wire:initial-data="{"fingerprint":{"id":"BCEos1ECXtGL114CYnTn","name":"nuevo-turno","locale":"es"},"effects":{"listeners":[]},"serverMemo":{"children":[],"errors":[],"htmlHash":"850cd1b2","data":{"qFecha":"2020-11-17"},"dataMeta":[],"checksum":"3cb32d8a817d51f7ff71a9ebeb184da10fb421dc1eb00e1ddd53a4ab30dcefb7"}}"!doctype html>
[解决方案]
我将 app.blade 格式从 @yield()
更改为 {{ $slot }}
。
还更改了 livewire 组件 nuevo-turno.blade:
<x-slot name="header">
Nuevo Turno
</x-slot>
<div>
{{ $qFecha }}
<input type="text" value="{{ $qFecha }}">
<div>
<br>
{{-- A good traveler has no fixed plans and is not intent upon arriving. --}}
{{ $formatoTurno->Distancia_Entre_Turnos }}
{{ $formatoTurno->Hora_Inicio }}
{{ $formatoTurno->Hora_Fin }}
</div>
</div>
现在可以了。 谢谢大家的回答!