引入layui的laydate组件失效的原因
标签少了加粗部份 th:inline=“none”
script type=“text/javascript”
th:inline="none"
<script type="text/javascript" th:inline="none">
layui.use(['simpleform','laydate','tableSelect'], function () {
var form = layui.form,
tableSelect = layui.tableSelect,
laydate= layui.laydate;
laydate.render({
elem: '#chargeStartTime'
, format: 'yyyyMMdd'
, trigger: 'click'
});
tableSelect.render({
elem: '#cgRoomIdText',
checkedKey: 'cgRoomId',
searchKey: 'cgRoomName',
table: {
url: 'v3/charge/baseRoom/pageList',
method: 'POST',
contentType: 'application/json',
parseData: function (res) {
return {
"code": res.code,
"msg": res.msg,
"count": res.data.total,
"data": res.data.records
};
},
response: {
statusCode: 200
},
cols: [[
{type: 'radio'}
, {field: 'baseRoomName', title: '房屋名称'}
]]
},
done: function (elem, data) {
var selectVal = [];
layui.each(data.data, function (index, item) {
selectVal.push(item.baseRoomName)
$('#belongRoomId').val(item.cgRoomId)
});
elem.val(selectVal.join(","))
}
});
setInputDisabled();
function setInputDisabled() {
if ($('[name="cellStateEnum"]:checked').val()=="1"){
$("#chargeStartTime").attr("class","layui-input layui-disabled");
$("#chargeStartTime").attr("disabled","disabled");
$("#period").attr("class","layui-input layui-disabled");
$("#period").attr("disabled","disabled");
}
};
form.on('radio(cellStateEnum)',function (data) {
console.log(data.value);
if (data.value=="1"){
$("#chargeStartTime").attr("class","layui-input layui-disabled");
$("#chargeStartTime").attr("disabled","disabled");
$("#period").attr("class","layui-input layui-disabled");
$("#period").attr("disabled","disabled");
}else {
$("#chargeStartTime").attr("class","layui-input");
$("#chargeStartTime").removeAttr("disabled");
$("#period").attr("class","layui-input");
$("#period").removeAttr("disabled");
}
})
});
</script>