Php 使用livewire更新更改?
我有Php 使用livewire更新更改?,php,laravel,laravel-livewire,Php,Laravel,Laravel Livewire,我有数量的输入类型编号: html代码: <span class="qty-btn minus-btn" onclick="this.parentNode.querySelector('input[type=number]').stepDown()"> <i class="fal fa-minus-circle"></i> </span> <input wire:
数量的输入类型编号
:
html代码:
<span class="qty-btn minus-btn" onclick="this.parentNode.querySelector('input[type=number]').stepDown()">
<i class="fal fa-minus-circle"></i>
</span>
<input
wire:model.lazy="quantity"
wire:change="updateQuantity({{ $product->id }})"
type="number"
class="input-text qty text"
title="Qty" inputmode="numeric"
step="1" min="1" max="" lang="en"
>
<span class="qty-btn plus-btn" onclick="this.parentNode.querySelector('input[type=number]').stepUp()">
<i class="fal fa-plus-circle"></i>
</span>
尝试
wire:单击
以和声
不要使用javascriptonclick
函数作为您使用的livewairesteppdown()
此函数您可以自己在livewire中编写抱歉,它没有:(@akin check nowCool谢谢,但是当我点击任何函数时,我如何更新数量?我还需要通过updateQuantity更新数量function@akin现在检查谢谢你兄弟:)
class CartQtySection extends Component
{
public $product;
public $quantity;
public function mount($product)
{
$this->product = $product;
$this->quantity = $product->pivot->quantity;
}
public function updateQuantity($id)
{
user()->cart()->updateExistingPivot($id, [
'quantity' => $this->quantity,
]);
$this->emit('quantityUpdated');
}
}