I have this alert component and in the body field im trying to use the const "item". The const "item" is in the Vue methods, is it possible to have 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]
...
CodePudding user response:
Before you continue with your project I would strongly suggest you go through the new Vue documentation. They have a great tutorial there for those who are new to Vue.
https://vuejs.org/tutorial/#step-1
It's very important to understand the basics before you start building things.
CodePudding user response:
Is it possible to have the const "item" result in that alert body field?
My Answer is No, Why you want to bind constant in your HTML template ? As you already have item property in your data object. You can update the item value in that property instead of assigning that in const
.
For Ex : this.item = 'item value'
instead of const item = 'item value'