我有這個(gè)警報(bào)組件,在正文字段中我嘗試使用 const“item”。 const“item”位于Vue方法中,是否可以在該警報(bào)主體字段中得到const“item”結(jié)果?我嘗試了 {item} {{item}} 但沒有成功。謝謝
<alert v-if="warning" :show-alert="showAlert" :options="{ body: "message" {item} {{item}} }" color="#ffc107" style="max-width: 670px; width: 100%;" @input="showAlert = false" /> ... export default { data () { return { warning: '', showAlert: true, item: null } }, ... methods: { const item = result.hits[0].refs.id[0] ...
我的答案是否定的,為什么要在 HTML 模板中綁定常量?因?yàn)槟臄?shù)據(jù)對(duì)象中已經(jīng)有 item 屬性。您可以更新該屬性中的項(xiàng)目值,而不是在 const
中分配該值。
例如: this.item = '項(xiàng)目值'
而不是 const item = '項(xiàng)目值'