Vue: Computed attributes based on Object not working

Created on 8 Apr 2016  路  2Comments  路  Source: vuejs/vue

Hi,

I discovered VueJS a few days ago and I am trying to use it for a web-app.
In the data object of a view, I have the following:

aView = new Vue({ el: '#filter', data: { testObject: {test:'test'}, test: 4 }, computed: { testObjectLength: function () { return Object.keys(this.testObject).length; }, testAdd: function () { return this.test+1; } } });

The problem is that the computed attribute testObjectLength is not updated when new elements are added to the object (filterView.testObject[new] = 'new'; in javascript console) whereas the testAdd attribute works perfectly.

What am I doing wrong? Is there another way to get the number of properties of a javascript object?

Thanks a lot
V

Most helpful comment

All 2 comments

Didn't see that one, sorry.
Thanks a lot

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robertleeplummerjr picture robertleeplummerjr  路  3Comments

aviggngyv picture aviggngyv  路  3Comments

paceband picture paceband  路  3Comments

gkiely picture gkiely  路  3Comments

finico picture finico  路  3Comments