Focus event

Report a typo

Look at the code below. What does @focus do in this example?

<template>
  <input type="text" @focus="changeBackground" @blur="resetBackground" v-bind:style="{backgroundColor: bgColor}">
</template>

<script>
export default {
  data() {
    return {
      bgColor: ''
    };
  },
  methods: {
    changeBackground() {
      this.bgColor = 'yellow';
    },
    resetBackground() {
      this.bgColor = '';
    }
  }
}
</script>
Select one option from the list
___

Create a free account to access the full topic