Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获类型错误:UICtrl.getDOMstrings不是函数_Javascript_Dom_Closures - Fatal编程技术网

Javascript 未捕获类型错误:UICtrl.getDOMstrings不是函数

Javascript 未捕获类型错误:UICtrl.getDOMstrings不是函数,javascript,dom,closures,Javascript,Dom,Closures,我在控制台中遇到的确切错误是: var budgetController = (function() { })(); //UI CONTROLLER var UIController = (function () { var DOMstrings = { //so i won't have to change '.add__type' for example everywhere in the code if i decide to modify my html

我在控制台中遇到的确切错误是:

var budgetController = (function() {


})();

//UI CONTROLLER
var UIController = (function () {

    var DOMstrings = {
        //so i won't have to change '.add__type' for example everywhere in the code if i decide to modify my html
        inputType: '.add__type',
        inputDescription: '.add__description',
        inputValue: '.add__value',
        inputBtn: '.add__btn'

    };

    return {
      getInput: function(){
          return {
              type: document.querySelector(DOMstrings.inputType).value,//will be wither inc or exp
              description: document.querySelector(DOMstrings.inputDescription).value,
              value: document.querySelector(DOMstrings.inputValue).value
          };

      },
        getDomstrings: function() {
            //exposing the domstring object to the public
            return DOMstrings;
        }
    };

})();


//GLOBAL APP CONTROLLER
var controller = (function(budgetCtrl,UICtrl) {

    var DOM = UICtrl.getDOMstrings();

    var ctrlAddItem = function () {

        //1. get the field input data
        var input = UICtrl.getInput();
        console.log(input);

        //2.Add the item to the budget controller

        //3.Add the item to the UI

        //4. Calculate the budget

        //5. Display the budget on the UI


    }

    document.querySelector(DOM.inputBtn).addEventListener('click',ctrlAddItem);

    document.addEventListener('keypress', function(event) {
        // enter has that key code(13)
        if (event.keyCode === 13 || event.which === 13) {
            ctrlAddItem();
        }

    });

})(budgetController,UIController);

正在积极学习javascript,并在错误上陷入困境,因为
。getDomstrings()
是上面定义的函数,是公共函数,因此应该可以访问它。可能不需要添加html,但如果评论中有,请告诉我。

Javascript是区分大小写的语言,使用时必须使用与语言关键字、函数、变量等完全相同的名称

因此,函数
getDomstrings
在被称为
getDomstrings
时无效

必须以
getDomstrings
的形式调用函数,或者将函数名更改为
getDomstrings
,然后才能以
getDomstrings
的形式调用函数

因此,请输入以下代码:

var-DOM=UICtrl.getDOMstrings()

应该是:

var-DOM=UICtrl.getDomstrings()

app.js:39 Uncaught TypeError: UICtrl.getDOMstrings is not a function
    at app.js:39
    at app.js:68
(anonymous) @ app.js:39
(anonymous) @ app.js:68