我正在尝试使用attr
绑定来设置属性 ( data-rating
),但我收到了错误消息:
错误:无法解析绑定。消息:SyntaxError: missing : after property id; 绑定值: attr: { data-rating: UserMovies[0].Rating }
attr 绑定不接受连字符的属性吗?
<ul class="content thumbnails" data-bind="foreach: movies, loader: $root.isLoading">
<li class="movie">
<div class="image">
<img data-bind="image: { src: Poster.Detailed, alt: Title }" />
<div class="actions">
<!-- ko if: UserMovies.length > 0 -->
<span class="raty" data-bind="attr: { data-rating: UserMovies[0].Rating }"></span>
<!-- /ko -->
</div>
</div>
</li>
</ul>