简体   繁体   中英

ko.observableArray() not adding elements

I'm trying out KO but have problems getting observableArray to work, the code is very simple

​var test = new ko.observableArray();
var regulararray = [];

test.push("item");
regulararray.push("regularpush");
console.log("the length for ko: " + test.length + " the length for regular array: " +    regulararray.length);​​

For some reason the length of the knockout array is 0 while the regular array length is 1.

Why is this happening?

使用test().length而不是test.length

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM