4 回答

TA貢獻1871條經驗 獲得超13個贊
使用javascript更改輸入值后,可以觸發輸入事件以使livewire更新模型。
document.getElementById("images").value = 'Hello'; document.getElementById("images").dispatchEvent(new Event('input'));
如果您使用wire:model.lazy,則應該使用“change”事件而不是“input”

TA貢獻1816條經驗 獲得超6個贊
<script>
document.addEventListener('livewire:load', function () {
@this.set('images','Hello');
//console.log('Hello');
});
</script>
創建一個公共屬性名稱“images”,在掛載中啟動它。我希望它能解決你的問題。讓我知道。

TA貢獻1797條經驗 獲得超6個贊
您可以使用 livewire 中的內聯腳本填充輸入字段,例如:
document.addEventListener('livewire:load',function ()
{
@this.images = "Hello";
});
<input type="text" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="images" wire:model="images">

TA貢獻1825條經驗 獲得超4個贊
在輸入字段的父元素上添加wire:ignore
喜歡
<div wire:ignore>
<input type="text" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="images" wire:model="images">
</div>
添加回答
舉報