Answers for "components vue watch"

8

vue watch deep

export default {
  name: 'ColorChange',
  props: {
    colors: {
      type: Array,
      required: true,
    },
  },
  watch: {
    colors: {
      // This will let Vue know to look inside the array
      deep: true,

      // We have to move our method to a handler field
      handler(value) {
        console.log('The list of colors has changed!', value);
      }
    }
  }
}
Posted by: Guest on June-09-2020
13

vue watch

var vm = new Vue({
  el: '#demo',
  data: {
    firstName: 'Foo',
    lastName: 'Bar',
    fullName: 'Foo Bar'
  },
  watch: {
    firstName: function (val) {
      this.fullName = val + ' ' + this.lastName
    },
    lastName: function (val) {
      this.fullName = this.firstName + ' ' + val
    }
  }
})
Posted by: Guest on March-12-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language