I am really new to Vue JS. Is there a way to change the input field background-color, once the value is updated as empty or ' '? Right now the code below consists of pre-defined value for teamfetch which 123456 and when the input field consists of value it displays the background-color as GREEN which is correct. But when I clicked on the @click:teamfetch event , it updates the value of teamfetch to empty or ' ' but the background-color of that input field does not change to WHITE or GRAY.
How can I change the background-color of the input-field to white when its empty?
View
<b-form-input v-model="teamfetch" v-on:input="postdata($event,
index)" :style="teamfetch ? { 'background-color': '#33FF90', color:'#33FF90' } : null"></b-form-input>
<b-icon icon="trash-fill" font-scale="1.5" @click="teamfetch='' " ></b-icon>
Script
import { BootstrapVueIcons } from 'bootstrap-vue'
import 'bootstrap-vue/dist/bootstrap-vue-icons.min.css'
Vue.use(BootstrapVueIcons)
data() {
return {
teamfetch: '123456'
}
}
teamfetch
to an empty String, which is still a valid value. In the style binding you should check id the String is null or empty, then it should work – Josef