0

我正在尝试创建一个简单的工作灯应用程序,但尝试创建一个新Memory的原因是: Uncaught TypeError: Cannot read property 'style' of null at mobile-ui-layer.js:378

这似乎很奇怪,因为我不明白创建 Memory 对象与样式有什么关系。

在 Chrome 中调试时,我var testStore = new Memory({data:storeData})在行之后立即得到它。

require (
                    ["dojo", 
                    "dojo/parser", 
                    "dojo/_base/xhr",
                    "dijit/form/ComboBox",  
                    "dojo/store/JsonRest", 
                    "dojo/ready",
                    "dojox/mobile/EdgeToEdgeStoreList",
                    "dojox/mobile",
                    "dojox/mobile/parser",
                    "dojox/io/xhrWindowNamePlugin",
                    "dojox/io/windowName", 
                    "dojox/io/xhrPlugins", 
                    "dojo/dom-style", 
                    "dojo/dom", 
                    "dojo/dom-class", 
                    "dojo/_base/Deferred",
                    "dojo/store/Memory"], function(JsonRestStore, EdgeToEdgeStoreList, xhrPlugins, Memory) {

            storeData = [
                                 { "label": "Wi-Fi", "icon": "images/i-icon-3.png", "rightText": "Off", "moveTo": "bar" },
                                 { "label": "VPN", "icon": "images/i-icon-4.png", "rightText": "VPN", "moveTo": "bar" }
                             ];
                    var testStore = new Memory({data:storeData});
                    var testList = new dojox.mobile.EdgeToEdgeStoreList({store:testStore}, "testList");
                    storeList.startup();
            });

供参考:这是worklight 5.0.5

4

1 回答 1

2

您的主要问题是require数组中的所有依赖项都需要与函数中的参数名称匹配。例如

require(['dep1','dep2','dep3'],function(dep1,dep2,dep3){});

所以推断一下

require(
["dojo",
  "dojo/parser",
  "dojo/_base/xhr",
  "dijit/form/ComboBox",
  "dojo/store/JsonRest",
  "dojo/ready",
  "dojox/mobile/EdgeToEdgeStoreList",
  "dojox/mobile",
  "dojox/mobile/parser",
  "dojox/io/xhrWindowNamePlugin",
  "dojox/io/windowName",
  "dojox/io/xhrPlugins",
  "dojo/dom-style",
  "dojo/dom",
  "dojo/dom-class",
  "dojo/_base/Deferred",
  "dojo/store/Memory"], function (dojo,parser,xhr,ComboBox,JsonRest,ready,EdgeToEdgetStoreList,mobile,parser,xhrPlugin,windowname,xhrPlugins,domStyle,dom,domClass,Deferred,Memory) {

  storeData = [{
    "label": "Wi-Fi",
    "icon": "images/i-icon-3.png",
    "rightText": "Off",
    "moveTo": "bar"
  }, {
    "label": "VPN",
    "icon": "images/i-icon-4.png",
    "rightText": "VPN",
    "moveTo": "bar"
  }];
    console.log(Memory);
  var testStore = new Memory({

    data: storeData
  });  
    var storeList = new dojox.mobile.EdgeToEdgeStoreList({
    store: testStore
  }, "testList");
  storeList.startup();

});

您的代码片段中发生的情况是该参数Memory实际上是一个不同于其名称所暗示的类。根据依赖数组顺序,它是一个EdgeToEdgeStoreList.

于 2013-01-15T13:18:04.533 回答