I want to set a property, by using Vue.set() in Nuxtjs application.
editPost(post) {
Vue.$set(post, 'edit', true)
}
Got error: Vue is not defined
I want to set a property, by using Vue.set() in Nuxtjs application.
editPost(post) {
Vue.$set(post, 'edit', true)
}
Got error: Vue is not defined
You can just use this instead of Vue.. This references the current vue component inside the method, so it will work same way:
editPost(post) {
this.$set(post, 'edit', true)
}
Sometimes you may want to assign a number of properties to an existing object, for example using Object.assign() or _.extend(). However, new properties added to the object will not trigger changes. In such cases, create a fresh object with properties from both the original object and the mixin object:
// instead of Object.assign(this.someObject, { a: 1, b: 2 })
this.someObject = Object.assign({}, this.someObject, { a: 1, b: 2 })