【问题标题】:tabulator how to import as es module?tabulator 如何导入为 es 模块?
【发布时间】:2021-11-27 10:02:50
【问题描述】:

我正在尝试在 svelte 中使用制表符。但似乎制表符没有将包类型公开为 package.json 文件中的模块。因此,我们不能将 tabulator_esm 作为模块导入。 当我尝试将其作为模块导入时,我收到来自vite 的错误,例如Unexpected token export。虽然还有其他导入方式,例如await import('tabulator-tables');

这个选项(`"type": "module")不应该在 package.json 中吗?

【问题讨论】:

  • https://codesandbox.io/s/condescending-silence-5emqr?file=/index.js

标签: tabulator


【解决方案1】:

您可以使用标准 esm import sytanx 导入 Tabulator,因为 Tabulator 库导出其核心功能与其模块分开,您需要确保导入所需的库位:

要获得基本的 Tabulator 核心功能:

import {Tabulator} from 'tabulator-tables';

要使用特定模块获得基本的 Tabulator 核心功能:

import {Tabulator, FormatModule, EditModule} from 'tabulator-tables';

Tabulator.registerModule([FormatModule, EditModule]);

要获得安装了所有模块的完整制表器(这将是一个更大的源文件:

import {TabulatorFull as Tabulator} from 'tabulator-tables';

【讨论】:

    猜你喜欢
    • 2019-09-24
    • 2021-04-04
    • 2021-10-30
    • 1970-01-01
    • 2019-07-14
    • 2021-04-07
    • 2021-10-13
    • 1970-01-01
    相关资源
    最近更新 更多