如何在Vue模板中使用Vue方法的常數來顯示常數結果?
P粉946437474
P粉946437474 2024-03-21 20:31:16
0
1
419

我有這個警報組件,在正文字段中我嘗試使用 const“item”。 const“item”位於Vue方法中,是否可以在該警報主體欄位中得到const“item”結果?我嘗試了 {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]

...

P粉946437474
P粉946437474

全部回覆(1)
P粉762447363

我的答案是否定的,為什麼要在 HTML 模板中綁定常數?因為您的資料物件中已經有 item 屬性。您可以更新該屬性中的項目值,而不是在 const 中指派該值。

例如: this.item = '項目值' 而不是 const item = '項目值'

#
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!