How to use constants of Vue methods in Vue templates to display constant results?
P粉946437474
P粉946437474 2024-03-21 20:31:16
0
1
416

I have this alert component and in the body field I try to use const "item". The const "item" is in the Vue method, is it possible to get the const "item" result in that alert body field? I tried {item} {{item}} without success. Thanks

<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

reply all(1)
P粉762447363

My answer is no, why should we bind constants in HTML templates? Because you already have item property in your data object. You can update the item value in this property instead of assigning the value in const.

For example: this.item = 'item value' instead of const item = 'item value'

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!