beforecreate vuejs code example
Example 1: vuejs set
Vue.set(vm.someObject, 'propertyName', value)
this.$set(this.someObject, 'propertyName', value)
this.$set(this.someArray, indexOfItem, value)
this.someObject = Object.assign({}, this.someObject, { a: 1, b: 2 })
Example 2: 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
}
}
})