Nig*_*gel 1 javascript luxon tabulator
使用 Tabulator 5.4,并尝试允许用户对包含日期的列进行排序,文档中告诉我:
需要依赖项您需要包含 luxon.js 库才能使用此排序器
但文档没有解释如何包含 luxon.js 库。
我已经使用安装了 luxon
npm install luxon
Run Code Online (Sandbox Code Playgroud)
我有
import {TabulatorFull as Tabulator} from 'tabulator-tables'
import { DateTime } from "luxon"
Run Code Online (Sandbox Code Playgroud)
然后,在表定义中:
{title: 'Modified', field: 'modifiedTime', sorter:"date", cssClass: 'grey'},
Run Code Online (Sandbox Code Playgroud)
但是当我运行这个时,我得到:
datetime.js:3 Uncaught ReferenceError: luxon is not defined
at Sort.datetime$2 (datetime.js:3:30)
at Sort.date$1 (date.js:9:18)
at Sort._sortRow (Sort.js:462:37)
at Sort.js:434:19
at Array.sort (<anonymous>)
at Sort._sortItems (Sort.js:428:8)
at Sort.sort (Sort.js:369:10)
at RowManager.refreshPipelines (RowManager.js:723:40)
at VirtualDomVertical.rerenderRows (VirtualDomVertical.js:98:4)
at RowManager.reRenderInPosition (RowManager.js:849:18)
Run Code Online (Sandbox Code Playgroud)
我认为我没有将 luxon 安装在正确的位置或以正确的方式。我该怎么做呢?
正如Timur所建议的,这将起作用:
import {DateTime} from 'luxon'
window.DateTime = DateTime
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1424 次 |
| 最近记录: |