1

我收到一个奇怪的错误。当我尝试实例化 TextArea 时,我得到 Uncaught TypeError: number is not a function。但是,如果我改为将其更改为 TextBox,则代码运行良好。我不认为我向构造函数传递了任何无效的东西,并且在我的代码中没有看到 TextArea 被覆盖的任何地方。在我在 else if 块中实例化它之前,我不会在我的代码中使用它。有任何想法吗?

array.forEach(listOfFields, function(item) {
    if(item === "Recent Rain") {
        tr = domConstruct.create("tr", {}, "displayDataForm"),
        td = domConstruct.create("td", {}, tr),
        td1 = domConstruct.create("td", {}, tr),
         l = domConstruct.create("label", {
             innerHTML: 'Rain in Last 24 Hours?: ',
             'class': 'dataFieldLabel',
             'for': item
         }, td, 'first'),
         r = new DropDownSelect({
             'class': 'dataField',
             name: item,
             title: item,
             options: [
                        { label: "Yes", value: "Yes" },
                        { label: "No", value: "No", selected: true },
                      ],
             'data-fieldType': 'DropDownSelect'
         }).placeAt(td1, 'last');
    }
    else if(item === 'Water Color or Odor' || item === 'Aquatic Life Present' || item === 'Site Change') {
        tr = domConstruct.create("tr", {}, "displayDataForm"),
        td = domConstruct.create("td", {}, tr),
        td1 = domConstruct.create("td", {}, tr),
         l = domConstruct.create("label", {
             innerHTML: item + ': ',
             'class': 'dataFieldLabel',
             'for': item
         }, td, 'first'),
         r = new TextArea({
             'class': 'dataField',
             name: item,
             title: item,
             'data-fieldType': 'TextArea'
         }).placeAt(td1, 'last');
    }
    else {
     tr = domConstruct.create("tr", {}, "displayDataForm"),
        td = domConstruct.create("td", {}, tr),
        td1 = domConstruct.create("td", {}, tr),
         l = domConstruct.create("label", {
             innerHTML: item + ': ',
             'class': 'dataFieldLabel',
             'for': item
         }, td, 'first'),
         r = new TextBox({
             'class': 'dataField',
             name: item,
             title: item,
             'data-fieldType': 'TextBox'
         }).placeAt(td1, 'last');
    }
});

更新

这是我的完整依赖项列表:

        require(["dojo/dom", "dojo/ready", "dojo/request", "dojo/dom-construct", "dojo/dom-attr", "dojo/_base/declare", "dojo/_base/array", "dijit/Dialog", "dijit/form/DateTextBox", "dijit/form/Form", "dijit/form/Button", "dijit/form/CheckBox", "dijit/form/TextBox", "dijit/form/TextArea", "dojox/form/DropDownSelect", "dojo/json", "dijit/registry", "dojo/query"],

                function(dom, ready, request, domConstruct, domAttr, declare, array, Dialog, DateTextBox, Form, Button, Checkbox, TextBox, TextArea, DropDownSelect, JSON, registry, query)

我正在使用 dijit/form/TextArea

4

0 回答 0