我有这样的Vue表2:
<template>
<v-server-table url="/"
:columns="orderListColumns"
:options="orderListOptions">
</v-server-table>
</template>
import moment from 'moment';
import { Event } from 'vue-tables-2';
export default {
name: 'order-list',
components: { FontAwesomeIcon, LoaderIcon },
mixins: [i18nMixin, userMixin],
data() {
return {
query: '',
orderList: [],
orderListColumns: [
'productDetailName',
'email',
'orderId',
'orderDate',
'type',
'paymentStatus',
'total',
],
isDataLoading: false,
};
},
computed: {
orderListOptions() {
return {
uniqueKey: 'orderId',
perPageValues: [],
sortable: [],
requestFunction: ({ page, limit, query }) =>
orderService.getOrdersByUser(
OrderSelectModel({
mcUserName: this.$_user.userName,
rowsPerPage: limit,
pageNumber: page - 1,
languageId: this.$_i18n_currentLanguageId,
code: query,
})
),
responseAdapter: ({ order, totalItems }) => {
const o = order;
const orderDate = moment(order.orderDate).format('MMMM Do YYYY');
o.orderDate = orderDate;
return {
data: o,
count: totalItems,
};
},
//etc
正如您在 responseAdapter 上看到的那样,我将数据分配为data: o
问题是当我收到我收到orderDate
的字段时:2018-06-12T19:58:41.73
并且我想使用 momentjs 对其进行格式化,因此在响应适配器中我尝试:
responseAdapter: ({ order, totalItems }) => {
const o = order;
const orderDate = moment(order.orderDate).format('MMMM Do YYYY');
o.orderDate = orderDate;
return {
data: o,
count: totalItems,
};
},
但它不起作用,它只是没有格式日期。我究竟做错了什么?问候