Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 矩:Array.prototype.some调用null或未定义_Javascript_Backbone.js_Momentjs_Daterangepicker_Bootstrap Daterangepicker - Fatal编程技术网

Javascript 矩:Array.prototype.some调用null或未定义

Javascript 矩:Array.prototype.some调用null或未定义,javascript,backbone.js,momentjs,daterangepicker,bootstrap-daterangepicker,Javascript,Backbone.js,Momentjs,Daterangepicker,Bootstrap Daterangepicker,仍然存在以下问题。我上周没有出现问题,也没有更改任何代码: 我在这里使用daterangepicker: 我的js代码: const Backbone = require('backbone'); const dutils = require('dutils'); const FilterGroupView = require('./filterGroupView'); const _ = require('underscore'); const $ = require('jquery'); c

仍然存在以下问题。我上周没有出现问题,也没有更改任何代码: 我在这里使用daterangepicker:

我的js代码:

const Backbone = require('backbone');
const dutils = require('dutils');
const FilterGroupView = require('./filterGroupView');
const _ = require('underscore');
const $ = require('jquery');
const moment = require('bootstrap-daterangepicker/moment');
require('bootstrap-daterangepicker');

const ranges = {
  'Today': [moment().startOf('day'), moment()],
  'Yesterday': [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')],
  'Last 7 Days': [moment().subtract(7, 'days'), moment()],
  'Last 30 Days': [moment().subtract(30, 'days'), moment()],
  'This Month': [moment().startOf('month'), moment().endOf('month')],
  'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
};

$('#dateForm').val(moment().subtract(7, 'days').format('YYYY-MM-DD HH:mm') + ' - ' + moment().format('YYYY-MM-DD HH:mm'));
console.log('ranges:' + JSON.stringify(ranges) ); // eslint-disable-line no-console
$('#dateForm').daterangepicker({
  format: 'YYYY-MM-DD HH:mm',
  minDate: new Date(2014, 0, 1),
  maxDate: new Date(),
  timePicker: true,
  timePickerIncrement: 30,
  showDropdowns: true,
  ranges: ranges, // Here
}, (start, end, label) => {
  $('#dateForm').val(start.format('YYYY-MM-DD HH:mm') + ' - ' + end.format('YYYY-MM-DD HH:mm'));
  if (label !== 'Custom Range') {
    this._relative_date = label;
  } else {
    this._relative_date = false;
  }
});
登录console.log如下所示:

analytics.bundle.js?v=v1.71:2 ranges:{"Today":["2016-04-18T04:00:00.000Z","2016-04-18T17:51:28.384Z"],"Yesterday":["2016-04-17T04:00:00.000Z","2016-04-18T03:59:59.999Z"],"Last 7 Days":["2016-04-11T17:51:28.385Z","2016-04-18T17:51:28.385Z"],"Last 30 Days":["2016-03-19T17:51:28.385Z","2016-04-18T17:51:28.385Z"],"This Month":["2016-04-01T04:00:00.000Z","2016-05-01T03:59:59.999Z"],"Last Month":["2016-03-01T05:00:00.000Z","2016-04-01T03:59:59.999Z"]}
上面的日志显示范围正常。console.log中的错误如下所示。如果我在上面的代码中删除了“ranges:ranges,//Here”,错误就会消失。我不明白为什么

Uncaught TypeError: Array.prototype.some called on null or undefined
错误的详细信息:

c   @   analytics.bundle.js?v=v1.71:16
Ue  @   analytics.bundle.js?v=v1.71:17
me  @   analytics.bundle.js?v=v1.71:17
n.setOptions    @   analytics.bundle.js?v=v1.71:16
n   @   analytics.bundle.js?v=v1.71:16
(anonymous function)    @   analytics.bundle.js?v=v1.71:16
vt.extend.each  @   commons.bundle.js?v=v1.71:14
vt.fn.vt.each   @   commons.bundle.js?v=v1.71:14
$.fn.daterangepicker    @   analytics.bundle.js?v=v1.71:16
t.exports.i.View.extend.initialize  @   analytics.bundle.js?v=v1.71:2
e.View  @   commons.bundle.js?v=v1.71:31
n   @   commons.bundle.js?v=v1.71:32
t.exports.i.View.extend.initialize  @   analytics.bundle.js?v=v1.71:1
e.View  @   commons.bundle.js?v=v1.71:31
n   @   commons.bundle.js?v=v1.71:32
(anonymous function)    @   analytics.bundle.js?v=v1.71:1
h   @   commons.bundle.js?v=v1.71:24
c.fireWith  @   commons.bundle.js?v=v1.71:24
vt.extend.ready @   commons.bundle.js?v=v1.71:24
c   @   commons.bundle.js?v=v1.71:14
package.json的一部分:

  "dependencies": {
    "backbone": "^1.2.0",
    "bootstrap": "^3.3.4",
    "bootstrap-daterangepicker": "git://github.com/dangrossman/bootstrap-daterangepicker.git#v1.3.21",
    "bootstrap-notify": "^3.1.3",
    "css-loader": "^0.12.1",
    "datatables": "git://github.com/DataTables/DataTables.git#1.10.7",
    "expose-loader": "^0.6.0",
    "extract-text-webpack-plugin": "^0.8.0",
    "file-loader": "^0.8.1",
    "html-loader": "^0.3.0",
    "imports-loader": "^0.6.3",
    "jquery": "^1.11.0",
    "jquery-ui": "^1.10.5",
    "style-loader": "^0.12.2",
    "underscore": "^1.8.3",
    "url-loader": "^0.5.5"
  }

这个问题似乎来自于11小时前发布的Moment2.13.0。我假设你的约会选择者把时间作为依赖项

同时…这将通过降级版本暂时解决您的问题。
npm卸载时刻
npm-imoment@2.12.0

更新:我创建了一个问题来跟踪这一点。

来自矩团队:我们认为您在这里看到的问题是,由于打包,2.13之前版本的矩对象正在被传递到2.13中的矩函数中。由于在2.13中对内部变量进行了更改,因此无法正常工作

目前,将力矩降到2.12将解决问题


我们将与一些更受欢迎的图书馆的作者交谈,看看我们能做些什么。我们将跟踪另一个答案中提到的进度。

将moment.js更新为最新版本的2.24.0为我解决了这个问题。它还修复了另一个问题,即向我们显示带有空白交付日期的记录。这些空白记录在更新到最新版本后停止显示。

对于遇到此问题的其他人,我在尝试发出一个HTTP请求时遇到了此问题,该请求的POST正文是一个对象,其值是矩的实例:

body = {
  foo: moment()
}
无法正确序列化矩()实例,我通过转换为ISO8601字符串解决了此问题:

body = {
  foo: moment().toISOString()
}

是的,我使用“const moment=require('bootstrap-daterangepicker/moment');”来导入矩。事实上,我不知道是哪个版本的时刻是进口。我是这个项目的新手。我正在使用Moment2.13.0更新我的评论,添加了一些进一步的信息。我刚刚注意到引导daterangepicker在11小时前更新了,但没有注意到那一刻也发布了。谢谢,小伙子,我能帮忙。与moment合作,现在在github threadHi上修复它。我来自moment团队。关于我们认为正在发生的事情,请参见下文。我们将不断更新此问题,以供将来的查找者使用。谢谢大家。