【问题标题】:DateRangePicker doesn't recognise carbon dateDateRangePicker 无法识别碳日期
【发布时间】:2016-07-25 10:39:08
【问题描述】:

将 Vue.js (Vue-Tables https://www.npmjs.com/package/vue-tables) 与 laravel 一起使用。 数据已成功显示,但 daterangepicker (http://www.daterangepicker.com/) 根本没有排序。 无论我设置什么间隔,记录都不会显示。正在使用 carbon 解析该字段以返回所需的格式

public function getFootageDateAttribute($date)
{
    return Carbon::parse($date)->format('d-m-Y');
}

在 js 文件中,我有 dateFormat: "DD-MM-YY", filterByColumn: true, dateColumns: ['footage_date'], 。当我使用 vue dev-tools 检查时,该字段是 footage_date: "03-04-2016"

如果我使用

对示例中的日期 (https://jsfiddle.net/matfish2/f5h8xwgn/) 进行硬编码

// 感谢 Tomasz Nurkiewicz (Elegant method to generate array of random dates within two dates)

function randomDate(start, end) {
  return moment(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
}

日期采用这种格式footage_date: "1974-03-27T18:19:40.364Z" 并且有效。

完整js文件http://pastebin.com/6hCe2eQL的Pastebin。客户端http://pastebin.com/xTUcAK98

【问题讨论】:

    标签: laravel vue.js php-carbon daterangepicker vue-resource


    【解决方案1】:

    素材日期应该作为时刻实例传递,而不是作为日期字符串,因此,修改就绪函数就可以了

     ready: function(){
            this.$http.get('/api/footage')
                .then(function(response){
                    footages = response.data
                    footages.forEach(footage => {
                        footage.footage_date = moment(footage.footage_date)
                    })
                    this.tableData = footages
                }.bind(this))
        }
    

    【讨论】:

      猜你喜欢
      • 2020-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 2020-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多