我收到此错误消息警告文本:DataTables警告:表ID = user_log_list-请求第0行的未知参数'Date',但是我的表可以正常工作并且可以正常加载。这是我的代码。我相信这与我在数据表中定义的列数或列数有关。以下是我的VUE组件文件。请告知。
<template>
<table id="user_log_list" class="table table-stripped table-bordered table-wordbreak">
</table>
</template>
<script>
export default {
name: 'tableLogs',
props: ['logs'],
data() {
return {
columns: [{
title: 'Date'
}, {
title: 'User'
}, {
title: 'Role'
}, {
title: 'Description'
}],
rows: [],
dt_handle: null
}
},
watch: {
logs(val) {
let tbl = this;
tbl.rows = [];
val.forEach(function(item) {
let row = [];
if(item.get_user) {
let role = item.get_user.user_type;
row.push(formatDate(item.local_created_at));
row.push(item.get_user.full_name);
row.push((role.charAt(0).toUpperCase() + role.slice(1)).replace('_', ' '));
row.push(item.description);
}
tbl.rows.push(row);
});
tbl.dt_handle.clear();
tbl.dt_handle.rows.add(tbl.rows);
tbl.dt_handle.draw();
}
},
mounted() {
let tbl = this;
tbl.dt_handle = $(this.$el).DataTable({
columns: tbl.columns,
data: tbl.rows,
searching: true,
paging: true,
info: true
});
}
}
function formatDate(local_created_at) {
let date = new Date(local_created_at);
let day = date.getDate();
let month = date.getMonth() + 1;
let year = date.getFullYear();
let hours = date.getHours();
let minutes = date.getMinutes();
let meridian = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12;
minutes = minutes < 10 ? '0'+minutes : minutes;
let time = hours + ':' + minutes + ' ' + meridian;
if (day < 10) {
day = '0' + day;
}
else if (month < 10) {
month = '0' + month;
}
return date = day + '/' + month + '/' + year + ' ' + time;
}
</script>
Lorem ipsum dolor坐下,奉献己任,sius do eiusmod tempor incididunt ut Labore et dolore magna aliqua。尽量不要抽烟,不要因抽烟而锻炼。 Duis aute irure dolor in reprehenderit in volttable velit esse cillum dolore eu fugiat nulla pariatur。不会出现意外的圣人,反而会在犯规的情况下动手动手。