Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vuejs set

Vue.set(vm.someObject, 'propertyName', value)
// Or using alias
this.$set(this.someObject, 'propertyName', value)
// For an array, simply repalce propertyName with the index
this.$set(this.someArray, indexOfItem, value)
// Or assign new props to an object
this.someObject = Object.assign({}, this.someObject, { a: 1, b: 2 })
Comment

this.$set in vue 3

VUE 2 >>>
data() {
  return {
    personObject: {
      name: 'John Doe'
    }
  }
},
methods: {
  addBio(bio) {
     this.$set(this.personObject, 'bio', bio)  // this was needed on vue 2
}

VUE 3 >>>
methods: {
  addBio(bio) {
     this.personObject['bio'] = bio   // no more this.$set in vue 3
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jest cross origin localhost fobbiden 
Javascript :: tagged templates 
Javascript :: input hook react 
Javascript :: jquery check if all elements hidden 
Javascript :: react native fetch response code 
Javascript :: back to top scroll animation jquery 
Javascript :: closure 
Javascript :: partial filter expression mongodb compass 
Javascript :: alpine js x-on click not working 
Javascript :: reduce method in javascript 
Javascript :: how to find remainder in javascript 
Javascript :: display none y display block infinito con javascript 
Javascript :: sum function in javascript 
Javascript :: dayofweek mongodb 
Javascript :: react pdf 
Javascript :: codemirror get object from textarea 
Javascript :: style.backgroundcolor 
Javascript :: jquery button click confirm and validate before submit 
Javascript :: indexof js 
Javascript :: react hook form 
Javascript :: moment get month day 
Javascript :: asynchronous function using function constructor 
Javascript :: components should be written as a pure function 
Javascript :: keep value after refresh javascript 
Javascript :: amcharts 
Javascript :: get all database react native 
Javascript :: write files in Node.js 
Javascript :: function javascript 
Javascript :: js regexp match 
Javascript :: javascript repeat function 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =