我正在重写一些Backbone代码,并得到一个奇怪的错误。这里是我的代码:
App.Views.ExploreCard.user = App.Views.ExploreCard.Parent.extend({
name: 'user',
allowUntyped: true,
classes: 'explore-person-box shadowed',
onclick: function() {
window.location.assign(this.data.profilePath);
},
postRender: function() {
App.HCS.redrawHCS(this.$el.find('.score'), this.$el.find('.user-card-avatar-round'));
}
});
和
App.HCS = {
redrawHCS: function(elements) {
elements.each(function(index, value, border) {
var score = $(value).html();
console.log(value);
console.log(border);
if (score <= 33 && score >= 1) {
$(value).css("background-color", "#ff4013");
$(border).css("border", "3px solid #ff4013;");
}
else if (score <= 66 && score >= 34) {
$(value).css("background-color", "rgb(92, 154, 0)");
$(border).css("border", "3px solid rgb(92, 154, 0)");
}
else if (score <= 99 && score >= 67) {
$(value).css("background-color", "#fb9f00");
$(border).css("border", "3px solid #fb9f00;");
}
});
}
};
当我这样做的价值和边境console.log
,我总是不确定的边境。我曾作为一个全面的检查切换参数在这条线:
来自:
App.HCS.redrawHCS(this.$el.find('.score'), this.$el.find('.user-card-avatar-round'));
到:
App.HCS.redrawHCS(this.$el.find('.user-card-avatar-round'), this.$el.find('.score'));
不管第二个参数的边界始终是不确定的顺序。
我在Backbone $el
上做了一些Google搜索,但没有找到任何修复。