[英]$.fn.dataTable.render.moment is not a function with npm
I got a basic issue in my application that i can't solve: i would like to format date in my datatable using moment like i have done in this script:我在我的应用程序中遇到了一个我无法解决的基本问题:我想像我在这个脚本中所做的那样使用 moment 在我的数据表中格式化日期:
$().ready(function() {
const FROM_PATTERN = 'YYYY-MM-DD HH:mm:ss.SSS';
const TO_PATTERN = 'DD/MM/YYYY HH:mm';
// liste des documents - INDEX
var listDocuments = $("#list-documents").DataTable({
processing:true,
serverSide:true,
scrollY:620,
autoWidth:true,
pageLength:25,
responsive:true,
scroller: {
loadingIndicator:true
},
ajax: {
url: $("#list-documents").attr('data-json')
},
columns: [
{data:'nom',name:'nom'},
{data:'uri',name:'uri',
"fnCreatedCell": function(nTd,sData,oData,iRow,iCol) {
$(nTd).html("<a href='" + oData.uri + "'>"+ oData.uri +"</a>")
}
},
{data:'updated_at',name:'updated_at',
render: $.fn.dataTable.render.moment(FROM_PATTERN,TO_PATTERN),
},
{data:'action',name:'action',orderable:false,searchable:false},
]
})
.on('draw',function() {
$("[data-toggle='tooltip']").tooltip()
})
})
The problem i had is that i got this error $.fn.dataTable.render.moment is not a function
.我遇到的问题是我收到此错误
$.fn.dataTable.render.moment is not a function
。 I'm using Laravel 8.54 with laravel-mix
.我将 Laravel 8.54 与
laravel-mix
一起使用。 Here is my app.js
where i load the libraries:这是我加载库的
app.js
:
require('./bootstrap');
$('.toast').toast('show')
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
window.$ = window.jQuery = require('jquery')
window.toastr = require('toastr')
require('moment')
require('../../node_modules/datatables.net/js/jquery.dataTables.js')
require('datetime-moment')
require('../../node_modules/datatables.net-bs4/js/dataTables.bootstrap4')
require('../../node_modules/jquery-ui/ui/widgets/autocomplete.js')
require('../../node_modules/jquery-ui/ui/widgets/sortable.js')
require('datatables.net-responsive')
I'm asking here because i saw many subjects treating this issue but none of these use npm. Does anyone has to deal with this issue?我在这里问是因为我看到很多主题都在处理这个问题,但没有一个使用 npm。有人必须处理这个问题吗? Thank in advance
预先感谢
It's a plugin code from datatables.net这是来自 datatables.net 的插件代码
You can download it from here: https://cdn.datatables.net/plug-ins/1.11.5/dataRender/datetime.js您可以从这里下载: https://cdn.datatables.net/plug-ins/1.11.5/dataRender/datetime.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.