我正在尝试从 dojo 网站扩展/修改一个示例,但遇到错误(使用 Firebug)并且不知道为什么。
这是在我的本地服务器上正常运行的原始教程:http: //dojotoolkit.org/documentation/tutorials/1.6/realtime_stores/demo/demo.html
现在我正在尝试添加一个 RequestMemory 存储:
require([
'dojo/_base/declare',
'dojo/Deferred',
'dstore/Memory',
'dstore/RequestMemory',
'dstore/QueryResults',
'dgrid/Grid',
'dgrid/OnDemandGrid',
'dgrid/extensions/Pagination',
"dgrid/List",
"dgrid/OnDemandGrid",
"dgrid/Selection",
"dgrid/editor",
"dgrid/Keyboard",
"dgrid/tree",
"dojo/_base/declare",
"dojo/store/JsonRest",
"dojo/store/Observable",
"dojo/store/Cache",
"dojo/store/Memory",
"dojo/_base/Deferred",
"dojo/query",
"dojo/dom",
"dojo/dom-construct",
"dojo/domReady!"
],
function (declare, Deferred, Memory, RequestMemory, QueryResults, Grid, OnDemandGrid, Pagination, Observable, JsonRest, query, dom, domConstruct) {
var data = [
{"name": "Dow Jones", "index": 12197.88, "date": new Date()},
{"name": "Nasdaq", "index": 2730.68, "date": new Date()},
{"name": "S&P 500", "index": 1310.19, "date": new Date()}
];
var store = new (declare(RequestMemory, {
fetchRange: function () {
// Override RequestMemory's fetchRange method with
// one that introduces a delay.
var dfd = new Deferred();
var promise = this.inherited(arguments);
promise.then(function (data) {
// Add an artificial delay of 1 second
setTimeout(function () {
dfd.resolve(data);
}, 1000);
});
return new QueryResults(dfd, {
totalLength: promise.totalLength
});
}
}))({
target: 'node_data.json'
});
... 跟原来的例子一样。
插入“RequestMemory”存储后,出现以下错误:
TypeError: marketStore.query is not a function
var results = marketStore.query({});
为什么?