2016-08-19 3 views

答えて

2

あり道場には相当ではない、とdojo/store/Memoryモジュールは、この目的のために意図されていない場合でも、あなたがコレクションとして何らかの方法でそれを使用することができ、これをチェックアウト:

require(["dojo/store/Memory"], function(Memory){ 
    var someData = [ 
     {id:1, name:"One"}, 
     {id:2, name:"Two"} 
    ]; 

    store = new Memory({ 
     idProperty: "id", //define the id property 
     data: someData 
    }); 

    // Returns the object with an id of 1 
    store.get(1); 

    // Returns query results from the array that match the given query 
    store.query({name:"One"}); 

    // Pass a function to do more complex querying 
    store.query(function(object){ 
     return object.id > 1; 
    }); 

    // Returns query results and sort by id 
    store.query({name:"One"}, {sort: [{attribute: "id"}]}); 

    // store the object with the given identity 
    store.put({id:3, name:"Three"}); 

    // delete the object 
    store.remove(3); 
}); 

道場は、他の種類を持っていますstoreの場合は、dojo/store/Memoryよりもあなたのケースに適しています。ここではドキュメントへのリンクです:

dojo/store/Memory
dojo/store/JsonRest
dojo/store/DataStore
dojo/store/Cache

は他人を存在するが、これは必須コモンズ

です
0

JavaScriptにCollectionがあるオブジェクトはありません。

var coll = { uid : "value" }; 
coll['uid2'] = "value2; 

の下にこれはこれではJavaScriptの美しさ

var a = coll['uid']; 

を使用してアクセスすることができるようにしかし、あなたは、独自のオブジェクトを作成することができます。

関連する問題