Jquery 引导datetimepicker-未捕获类型错误:无法读取属性;“获取时间”;未定义的

Jquery 引导datetimepicker-未捕获类型错误:无法读取属性;“获取时间”;未定义的,jquery,twitter-bootstrap,datetimepicker,bootstrap-datetimepicker,Jquery,Twitter Bootstrap,Datetimepicker,Bootstrap Datetimepicker,未捕获类型错误:无法读取未定义的属性“getTime” 您可以找到错误日志 插入到弹出窗口中 $('#edit').click(function(){ $.ajax({ url: "{:U('SystemSettingMgt/settingConf')}", type: 'post', data: { 'id' : $(this).siblings('input').val(), 'is_ac

未捕获类型错误:无法读取未定义的属性“getTime”
您可以找到错误日志

插入到弹出窗口中

$('#edit').click(function(){
    $.ajax({
        url: "{:U('SystemSettingMgt/settingConf')}",
        type: 'post',
        data: {
            'id' : $(this).siblings('input').val(),
            'is_active' : 1,
        },
        success:function(json){
            $('.modal-body').children().empty();
            var str = '';
            switch(json.datatype){
                // yes/false
                case "1":
                    str += '<label>select setting</label>';
                    str += '<input type="hidden" id="id" value="'+json.id+'">';
                    str += '<input type="hidden" id="datatype" value="'+json.datatype+'">';
                    str += '<select name="value" id="value" class="form-control">';
                    if (json.value == 1) {
                        str += '<option value="1" selected>yes</option>';
                        str += '<option value="0"false</option>';
                    }else if(json.value == 0){
                        str += '<option value="1">yes</option>';
                        str += '<option value="0" selected>false</option>';
                    }
                    str += '</select>';
                    $('.modal-body').children().append(str);
                    break;

                // enter string
                case "2":
                    str += '<label>enter setting</label>';
                    str += '<input type="hidden" id="id" value="'+json.id+'">';
                    str += '<input type="hidden" id="datatype" value="'+json.datatype+'">';
                    str += '<input name="value" id="value" class="form-control" value="'+json.value+'">';
                    $('.modal-body').children().append(str);
                    break;

                // enter num
                case "3":
                    str += '<label>select setting</label>';
                    str += '<input type="hidden" id="id" value="'+json.id+'">';
                    str += '<input type="hidden" id="datatype" value="'+json.datatype+'">';
                    str += '<input type="text" id="value" value="'+json.value+'" name="value" class="form-control" placeholder="设定值"  onkeyup="if(! /^\d+$/.test(this.value)){this.placeholder='+'只能整数'+';this.value='+';}">';
                    $('.modal-body').children().append(str);
                    break;

                // select date
                case "4":
                    str += '<label>select setting</label>';
                    str += '<input type="hidden" id="id" value="'+json.id+'">';
                    str += '<input type="hidden" id="datatype" value="'+json.datatype+'">';
                    str += '<input type="text" id="date" name="value" class="form-control date" placeholder="select date" value="'+json.value+'">';
                    $('.modal-body').children().append(str);
                    break;

                // date
                case "5":
                    str += '<label>change setting</label>';
                    str += '<input type="hidden" id="id" value="'+json.id+'">';
                    str += '<input type="hidden" id="datatype" value="'+json.datatype+'">';
                    str += '<input type="text" data-date-format="hh:ii" id="time" name="value" class="form-control date" placeholder="select time" value="'+json.value+'">';
                    $('.modal-body').children().append(str);
                    break;

                // select
                case "6":
                    str += '<label>change setting</label>';
                    str += '<input type="hidden" id="id" value="'+json.id+'">';
                    str += '<input type="hidden" id="datatype" value="'+json.datatype+'">';
                    str += '<select name="datasource"  id="value" class="form-control">';
                    for(i = 0; i < json.datasource.length; i++){
                        str += '<option value="'+i+'">'+json.datasource[i]+'</option>';
                    }
                    str += '</select>';
                    $('.modal-body').children().append(str);
                    break;
               }
         }
    });
    $('#editSetting').modal('show');
});
$(“#编辑”)。单击(函数(){
$.ajax({
url:“{:U('SystemSettingMgt/settingConf')}”,
键入:“post”,
数据:{
'id':$(this.sibbines('input').val(),
“是否处于活动状态”:1,
},
成功:函数(json){
$('.modal body').children().empty();
var-str='';
开关(json.datatype){
//是/否
案例“1”:
str+=“选择设置”;
str+='';
str+='';
str+='';
if(json.value==1){
str+=“是”;
str+='
未捕获的TypeError:无法读取未定义的属性“getTime”

未包含jQuery UI插件时引发此错误。
确保将它包含在项目中任何其他脚本之前,jQuery插件之后除外

未捕获的TypeError:无法读取未定义的属性“getTime”

未包含jQuery UI插件时引发此错误。

确保将其包含在项目中任何其他脚本之前,jQuery插件之后除外。

在bootstrap-datetimepicker.js中是:

getDate: function () {
      var d = this.getUTCDate();
      if (d === null) {
        return null;
      }
      return new Date(d.getTime() + (d.getTimezoneOffset() * 60000));
    },
但当设置为输入值时,例如:12:15,则d未定义。您可以在代码中重写getUTCDate函数,或者更改为:

d === null || typeof d  ==='undefined'

在bootstrap-datetimepicker.js中:

getDate: function () {
      var d = this.getUTCDate();
      if (d === null) {
        return null;
      }
      return new Date(d.getTime() + (d.getTimezoneOffset() * 60000));
    },
但当设置为输入值时,例如:12:15,则d未定义。您可以在代码中重写getUTCDate函数,或者更改为:

d === null || typeof d  ==='undefined'

请共享您的代码Fiddle请共享您的代码Fiddle但是在其他页面上,相同的代码是可以的。我猜这是jquery冲突,但也被拒绝了即使在其他页面上,相同的代码是可以的,对于这个页面,jquery库的jquery调用的层次结构可能不同。因此,在这个页面上相同的代码可能会失败,因为jQuery库导入顺序的e。我发现了问题,是问题的时间格式,使用json.value加go,但将给出,我现在需要解决时间格式的问题,但在其他页面上,相同的代码是可以的。我猜这是jQuery冲突,但也被拒绝了。尽管如此,在其他页面中相同的代码是可以的,对于这个页面t对jQuery库的jQuery调用的层次结构可能不同。因此,由于jQuery库导入的顺序,可能相同的代码在此页面中失败。我发现了问题,是问题的时间格式,使用json.value加go,但会给出,我现在需要解决时间格式的问题