Answer the question
In order to leave comments, you need to log in
How to call a computed property recalculation if it depends on a change in an array element?
There is a computed array property arrA.
data: {
arrB: []
},
computed: {
arrA: function () {
return this.arrB;
}
}
func1: function( i ) {
this.arrB[ i ] = 'значение' // Если оперировать на уровне элементов, то arrA() не будет вызвана
}
func2: function() {
this.arrB = [ 'значение', 'ещё значение', 'и ещё' ]; // Если изменить ссылку на массив, то arrA() будет вызвана
}
func3: function( i ) {
var tempArr = clone( this.arrB ); // Клонирование массива
tempArr[ i ] = 'значение';
this.arrB = tempArr;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question