引入layui的laydate组件失效的原因

引入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) { //res 即为原始返回的数据
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.records //解析数据列表
                    };
                },
                response: {
                    statusCode: 200 //重新规定成功的状态码为 200,table 组件默认为 0
                },
                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); //被点击的radio的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>

你可能感兴趣的:(引入layui的laydate组件失效的原因)