Vue computed property with an array not updating
Props are not Reactive. Use data:
Vue.component('test', {
props:['myarray'],
data: function() {
return {
arr: this.myarray.slice()
}
},
template:'#arraybug',
methods:{
add:function(){
this.arr.push(1);
}
},
computed:{
mycomputed: function(){
let newLen = this.arr.length;
return newLen;
}
}
});
var test = new Vue({
el:"#test"});
I'm copied props array to data.