我正在尝试创建一个自定义的下拉列表来更改alpinejs按钮的图标,因为我不能使用默认的select and options html
进行图标或样式设置
这是要更新的livewire代码图标
public function updateTagIcon($id,$value)
{
$this->icon = $value;
$this->validate([
'icon' => 'required',
]);
$this->tag->update(['icon' => $this->icon]);
$this->tag=Tag::find($this->tag->id);
}
有没有办法用alpineJS做@click
来设置$value=1
并将其传递给livewire?
或者,也许有一种方法可以通过wire:click任意设置此数据?
<div wire:click="updateTagIcon({{$tag->id}},'{{$value=2}}')">
<button type="button">
<svg> //</svg>
{{$tag->title}}
</button>
</div>
我在考虑可能会发出一个高山@click事件,但仍然不确定如何传递一个值来更新livewire中的$icon
发布于 2021-05-03 21:15:18
下面是如何设置值
wire:click="updateTagIcon({{$tag->id}},7)"
比livewire函数看起来更像
public function updateTagIcon($id,$icon)
{
$this->icon = $icon;
$this->validate([
'icon' => 'required',
]);
$this->tag->update(['icon' => $this->icon]);
$this->tag=Tag::find($this->tag->id);
}
https://stackoverflow.com/questions/67363723
复制相似问题