关闭我的函数时出现意外的标识符错误

时间:2018-06-21 19:19:11

标签: javascript

我收到关于“意外标识符”的错误消息,我不确定为什么。错误消息说它是针对“ getDOMstrings function(){”行的。有人知道我为什么会出错吗?

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

  var DOMstrings = {
    inputType: ".add__type",
    inputDescription: ".add__description",
    inputValue: ".add__value",
    inputBtn: '.add__btn'
  };

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

  }
})();

2 个答案:

答案 0 :(得分:1)

两个功能之间没有逗号。

  return {
    getInput: function() {
      return{
        type: document.querySelector(DOMstrings.inputType).value,  // will be either inc or exp
        description: document.querySelector(DOMstrings.inputDescription).value,
        value: document.querySelector(DOMstrings.inputValue).value
      }
    }, // Added this guy
    getDOMstrings: function () {
      return DOMstrings
    }

  }

答案 1 :(得分:1)

在上一行的结尾}末尾缺少逗号。