无法使用制表符构建自定义模块

问题描述 投票:0回答:1

我在 TypeScript 应用程序中使用 Tabulator 版本 5.5.4,并打算开发一个自定义模块。我正在按照Tabulator文档中概述的步骤进行操作。但是,我在自定义模块创建过程中遇到了错误,下面提供了具体的错误消息。

自定义模块.ts

import * as Tabulator from "tabulator-tables";
    class CustomModule extends Tabulator.Module{
        constructor(table){
            super(table);
    
            //register table options
            //register column options
            //register table functions
            //register component functions
        }
    
        initialize(){
            //subscribe to internal events
            //register data handlers
        }
    }
    
    CustomModule.moduleName = "custom";

表.ts

import * as Tabulator from "tabulator-tables";
Tabulator.Tabulator.registerModule(CustomModule );

环境配置:

  • @类型/制表符表 5.5.7
  • 制表器表格 5.5.4
  • tsconfig.json
    • 目标:es5
    • 模块:amd
javascript tabulator
1个回答
0
投票

更好的做法是从库中显式导入您需要的功能,这样树摇动将通过仅导入使用功能来改善代码大小

import {Module} as Tabulator from "tabulator-tables";
    class CustomModule extends Module{
import {Tabulator} as Tabulator from "tabulator-tables";
Tabulator.registerModule(CustomModule);
© www.soinside.com 2019 - 2024. All rights reserved.