Javascript 韩元';t return对象,它只返回代码段
所以我在做一个项目,这是我课程的一部分。我一直在跟踪,然后我必须将一个对象返回到控制台来测试一些东西,唯一的问题是,它不返回对象,它只返回对象所在的代码部分,包括注释之类的内容。代码如下:Javascript 韩元';t return对象,它只返回代码段,javascript,object,Javascript,Object,所以我在做一个项目,这是我课程的一部分。我一直在跟踪,然后我必须将一个对象返回到控制台来测试一些东西,唯一的问题是,它不返回对象,它只返回对象所在的代码部分,包括注释之类的内容。代码如下: var UIController = (function() { var DOMstrings = { inputType: '.add__type', inputDescription: '.add__description', inputValue: '.add__value',
var UIController = (function() {
var DOMstrings = {
inputType: '.add__type',
inputDescription: '.add__description',
inputValue: '.add__value',
inputBtn: '.add__btn',
incomeContainer: '.income__list',
expensesContainer: '.expenses__list',
budgetLabel: '.budget__value',
incomeLabel: '.budget__income--value',
expensesLabel: '.budget__expenses--value',
percentageLabel: '.budget__expenses--percentage',
container: '.container',
expensesPercLabel: '.item__percentage',
dateLabel: '.budget__title--month'
};
return {
getinput: function() {
var items = {
type: document.querySelector(DOMstrings.inputType).nodeValue,
description: document.querySelector(DOMstrings.inputDescription).nodeValue,
value: document.querySelector(DOMstrings.inputValue).nodeValue
}
return items;
}
}
}
)();
// Global App Controller
var controller = (function(budgetCtrl, UICtrl) {
var ctrlAddItem = function() {
// 1. Get the filled input data
var input = UICtrl.getinput;
console.log(input);
// 2. Add the item to the budget controller
// 3. Add the new item to the user interface
// 4. Calculate the budget
// 5. Display the budget on the UI
}
document.querySelector('.add__btn').addEventListener('click', ctrlAddItem);
// Make the ENTER key do what the CLICK does
document.addEventListener('keypress', function(event) {
if (event.keyCode === 13 || event.which === 13) {
console.log('ENTER was pressed');
ctrlAddItem();
}
} );
})(budgetController, UIController);
以下是输出:
ƒ () {
var items = {
type: document.querySelector(DOMstrings.inputType).nodeValue,
description: document.querySelector(DOMstrings.inputDescription).nodeV…
提前感谢。更改
var-input=UICtrl.getinput
intovar-input=UICtrl.getinput()代码>请在点击“post”后检查您的问题,以确保它看起来确实正确。在这种情况下,它肯定不是,请编辑它并修复代码格式?UICtrl.getinput()
,添加()
来调用函数。omg我认为它不是函数,因为函数会返回一个对象。成功了,谢谢!