Bootstap datetimepicker报错TypeError: intermediate value(转)

原文转自:http://blog.chinaunix.net/uid-20332519-id-5733546.html

Bootstrap datetimepicker有多个版本,官方的链接中,只是datepicker,没有时间的选择,原版的datetimepicker也不再更新,不能用新版的jquery。
现在https://github.com/Eonasdan/bootstrap-datetimepicker这个版本最完善,但是一大堆依赖很头疼;
https://github.com/smalot/bootstrap-datetimepicker还不错,比较轻巧,但是用起来报错。

报错:

    TypeError: (intermediate value).toString(...).split(...)[1] is undefined

    ...d"?false:k.title;this.defaultTimeZone=(new Date()).toString().split("(

原文:

    this.defaultTimeZone=(new Date()).toString().split("(")[1].slice(0,-1);

意思为:先取得Date对象,然后再字符串化,再用(来分隔字符串,然后取其中的第二个,再从右向左取第一项,也就是取时区项。
但在Firefox中,字符串化的结果为:“Wed May 25 2016 16:07:14 GMT+0800”,没有括号,导致错误。

更为通用的,时区可以用getTimezoneOffset()来获取,这个结果的单位是分钟,所以要除以60才可以:
修改为:

this.defaultTimeZone=‘GMT ‘+(new Date()).getTimezoneOffset()/60

修改后就可以正常使用了。

    this.fontAwesome=k.fontAwesome||this.element.data("font-awesome")||false;

改为:

    this.fontAwesome=true

另外还有一个字体错误,如果使用了fa字体,则会报错,系统中会检测不到fontAwesome,所以可以直接赋这个变量为true:

时间: 2024-08-27 19:48:16

Bootstap datetimepicker报错TypeError: intermediate value(转)的相关文章

Bootstap datetimepicker报错TypeError: intermediate value

Bootstrap datetimepicker有多个版本,官方的链接中,只是datepicker,没有时间的选择,原版的datetimepicker也不再更新,不能用新版的jquery.现在https://github.com/Eonasdan/bootstrap-datetimepicker这个版本最完善,但是一大堆依赖很头疼:https://github.com/smalot/bootstrap-datetimepicker还不错,比较轻巧,但是用起来报错. 报错: TypeError: 

python框架Scrapy报错TypeError: 'float' object is not iterable解决

原因是:Twisted版本高了. 解决办法: 只要把Twisted库降级到16.6.0即可: 1 pip3 install Twisted==16.6.0 2 3 注:Twisted16.6.0安装后,会自动卸载高版本的Twisted python框架Scrapy报错TypeError: 'float' object is not iterable解决

[转载]UEditor报错TypeError: me.body is undefined

本文转载来自:UEditor报错TypeError: me.body is undefined 今天在使用UEditor的setContent的时候报错,报错代码如下 TypeError: me.body is undefined 或 Uncaught TypeError: Cannot set property 'innerHTML' of undefined 错误的原因是没有等UEditor创建完成就使用UEditor的setContent函数了,可以通过如下代码解决 方法一: uedito

python 报错TypeError: 'range' object does not support item assignment,解决方法

贴问题 nums = range(5)#range is a built-in function that creates a list of integers print(nums)#prints "[0,1,2,3,4]" print(nums[2:4])#Get a slice from index 2 to 4 (exclusive); prints '[2,3]" print(nums[2:])#Get a slice from index 2 to the end

VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法

正常情况下在data里面都有做了定义 在函数里面进行赋值 这时候你运行时会发现,数据可以请求到,但是会报错 TypeError: Cannot set property 'listgroup' of undefined 主要原因是: 在 then的内部不能使用Vue的实例化的this, 因为在内部 this 没有被绑定.可以看下 Stackoverflow 的解释: 解决办法: 1.用ES6箭头函数,箭头方法可以和父方法共享变量 2.在请求axios外面定义一下 var that=this 问题

使用webpack命令打包时,报错TypeError: Cannot read property 'presetToOptions' of undefined的解决办法

我只安装了webpack,没有安装webpack-cli,第一次输入webpack打包时,提示 One CLI for webpack must be installed. These are recommended choices, delivered as separate packages: - webpack-cli (https://github.com/webpack/webpack-cli) The original webpack full-featured CLI. We wi

VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法

created() { var that=this axios.get('http://jsonplaceholder.typicode.com/todos') .then(function (res) { // handle success // console.log(res); that.todos = res.data }) .catch(function (error) { // handle error console.log(error); }) .finally(function

IE8 jquery ajax获取静态资源报错TypeError 拒绝访问

1. 出现问题的代码 /*** * 请求静态html 模板 * @param url * @param $jqueryDiv : 四个主要div之一 * @param templateHandle : 自定义,用于使用Dot js模板函数 * @param callback : 用于实现模板之后,绑定事件 * @param templateData : cia的返回数据 */ ajaxHtml: function (url, $jqueryDiv, templateHandle, callbac

使用Vue报错 --- "TypeError: fn.bind is not a function"

使用Vue报错[Vue warn]: Error in nextTick: "TypeError: fn.bind is not a function"页面进不去. 解决思路: (1)看报错信息是methods里有个方法你写的并不是一个函数,可能写了个对象什么的,vue进行fn.bind()处理的时候,.bind取到的可能是undefined. (2) 检查一下你methods里面的方法  ,  看看data mounted methods 写的是方法还是对象 原文地址:https:/