这是我的代码:
dojo.xhrGet({
url: "/api/products",
load: function (result) {
require([
"dojo/store/Memory", "dijit/form/ComboBox", "dojo/domReady!"
], function (Memory, ComboBox) {
console.log(result); // this outputs the data successfully...
var stateStore = new Memory({
data: result // but, this says it's "undefined"
});
var comboBox = new ComboBox({
id: "stateSelect",
store: stateStore,
searchAttr: "Name"
}, "stateSelect");
});
}
});
正如您从我上面的评论中看到的那样,数据在 my 中正确输出console.log()
,但是当我尝试在其中使用它时,new Memory()
它说它是“未定义的”。如何正确地用 JSON 数据填充我的 ComboBox?