造成我麻烦的守则有:
addListItem: function(obj, type) {
var html, newHtml, element;
// Create HTML string with placeholder text
if (type === inc ) {
element = DOMStrings.incomeContainer;
html = <div class="item clearfix" id="inc-%id%"> <div class="item__description">%description%</div><div class="right clearfix"><div class="item__value">%value%</div><div class="item__delete"><button class="item__delete--btn"><i class="ion-ios-close-outline"></i></button></div></div></div> ;
} else if (type === exp ) {
element = DOMStrings.expensesContainer;
html = <div class="item clearfix" id="exp-%id%"><div class="item__description">%description%</div><div class="right clearfix"><div class="item__value">%value%</div><div class="item__percentage">21%</div><div class="item__delete"><button class="item__delete--btn"><i class="ion-ios-close-outline"></i></button></div></div></div> ;
}
// Replace the placeholder text with some actual data
newHtml = html.replace( %id% , obj.id);
newHtml = newHtml.replace( %description% , obj.description);
newHtml = newHtml.replace( %value% , formatNumber(obj.value));
// Insert the HTML into the DOM
document.querySelector(element).insertAdjacentHTML( beforeend , newHtml);
},
getDomStrings: function() {
return DOMStrings
}
它坚持说话语种不作定义,但我可以诚实地发现造成错误的原因。