修复:礼物 JSON 数据破坏 Alpine.js x-data 属性解析
- 将 Js::from() 移到 script 标签输出为全局变量 - Alpine 组件通过 window.__gifts 引用,避免双引号冲突
This commit is contained in:
@@ -63,6 +63,11 @@
|
|||||||
|
|
||||||
{{-- ═══════════ 用户名片弹窗 (Alpine.js) ═══════════ --}}
|
{{-- ═══════════ 用户名片弹窗 (Alpine.js) ═══════════ --}}
|
||||||
@php $gifts = \App\Models\Gift::activeList(); @endphp
|
@php $gifts = \App\Models\Gift::activeList(); @endphp
|
||||||
|
<script>
|
||||||
|
// 礼物数据注入(避免 JSON 破坏 x-data 属性解析)
|
||||||
|
window.__gifts = {!! Js::from($gifts) !!};
|
||||||
|
window.__defaultGiftId = {{ $gifts->first()?->id ?? 0 }};
|
||||||
|
</script>
|
||||||
<div id="user-modal-container" x-data="{
|
<div id="user-modal-container" x-data="{
|
||||||
showUserModal: false,
|
showUserModal: false,
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
@@ -72,8 +77,8 @@
|
|||||||
whisperList: [],
|
whisperList: [],
|
||||||
showAnnounce: false,
|
showAnnounce: false,
|
||||||
announceText: '',
|
announceText: '',
|
||||||
gifts: {{ Js::from($gifts) }},
|
gifts: window.__gifts || [],
|
||||||
selectedGiftId: {{ $gifts->first()?->id ?? 0 }},
|
selectedGiftId: window.__defaultGiftId || 0,
|
||||||
giftCount: 1,
|
giftCount: 1,
|
||||||
sendingGift: false,
|
sendingGift: false,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user