Alpinejs将预填充的值传递给X模型
我有一个可以动态价值的表格,我想最初将其传递给X模型。
我该如何实现?在这种情况下,最好做什么?
hier是一个示例
<input name="zip" type="text" autocomplete="off" placeholder="{{__('PLZ, Ort', 'bdb')}}" value="{{$currentZip ?? ''}}"
x-model="formData.zip">
formdata.zip
即使填充值$ currentzip
,也将是空的。
I have a form which can receive dynamically value and I would like to pass this initially to x-model.
How can I achieve this? What are the best to goes in this case?
Hier is an example
<input name="zip" type="text" autocomplete="off" placeholder="{{__('PLZ, Ort', 'bdb')}}" value="{{$currentZip ?? ''}}"
x-model="formData.zip">
formData.zip
will be empty even if the value is filled $currentZip
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在每个输入元素上具有
x-init
指令,您可以在其中设置可选的动态值:You can have an
x-init
directive on each input element, where you can set the optional dynamic value: