使用[[${}]]
进行传值
layui官方说明
星星评分:
<div class=" layui-col-md2 " th:id="'a'+${comments.getId()}" style=""></div>
<script>
layui.use('rate', function () {
var rate = layui.rate;
var ins1 = rate.render({
elem: a[[${comments.getId()}]] //绑定元素(+a解决不能为全数字)
, length: 5 //星星个数
, value: [[${comments.getGrade()}]] //初始化值
, theme: ' gold' //颜色
, half: true //支持半颗星
, text: true //显示文本
, readonly: true //只读
//自定义文本,点击后文本显示的内容
, setText: function () {
this.span.text([[${comments.getGrade()}]]+'.0')
}
});
});
</script>