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>
添加回答
举报