I have a div on my website
<div class="ui-alert" v-show="isCaptchaError"> ... </div>
The variable isCaptchaError is initialized in my Vue instance:
const form = new Vue({
el: '#main-form',
data: {
isCaptchaError: false,
},
In a watcher for my input field, I make an axios request and set this.isCaptchaError to true
const form = new Vue({
el: '#main-form',
...
watch: {
phoneNumber(val) {
axios({
method: 'post',
url: '/rest/client',
data: ajaxRequest
}).then(function (response) {
this.isCaptchaError = true;
})
}
}
However, the div does not show. If I manually set this.isCaptchaError to true on a button click, the div displays as expected
How can I toggle the visibility of the div based on the result of the axios request?