我使用 raty 插件来显示多个项目的评分星。我初始化了一个数据属性的评分,比如
<span class="rating_score" data-rating="{{ review.rating}}" ></span>
然后我跑遍了所有课程,然后按照以下方式启动了比率
jQuery(".rating_score").each(function() {
$_this = jQuery(this);
console.log(($_this.attr('data-rating') ));
jQuery(this).raty({
path: '/bundles/gfx/rating/',
starOn: 'star.gif',
starOff: 'star_empty.gif',
hintList: ['1', '2', '3', '4', '5'],
scoreName: 'rating',
start: ($_this.attr('data-rating') ),
width: 13,
readOnly: true
});
});
问题是每个项目显示的评分值都相同,片段中有什么问题