如何在 React Bootstrap 表的列定义中使用矩库? [英] How to use the moment library in React Bootstrap table's column definition?

查看:67
本文介绍了如何在 React Bootstrap 表的列定义中使用矩库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

const columns = [{
  dataField: 'Id',
  text: 'Order ID'
}, {
  dataField: 'Date',
  text: 'Date'
}, {
  dataField: 'Total',
  text: 'Total'
}];

它在 React Bootstrap 表中显示日期.但是,日期是我不需要的 Json 格式.

And it displays date in React Bootstrap table. But, the date is in Json format that I don't need.

我尝试使用矩库以这种方式格式化日期:

I've tried to use the moment library to format date in this way:

const columns = [{
  dataField: 'Id',
  text: 'Order ID'
}, {
  dataField: '{moment(Date).format("DD-MM-YYYY")}',
  text: 'Date'
}, {
  dataField: 'Total',
  text: 'Total'
}];

但是,日期列是空的.

如何使用 moment 库来格式化 React Bootstrap 表库中列的日期?或者有其他方法可以做到吗?

How can I use the moment library to format the dates for columns in React Bootstrap table's library? Or there is some another way to do it?

推荐答案

column.formatter 可以帮助你.有一个在线演示:this

这篇关于如何在 React Bootstrap 表的列定义中使用矩库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆