gpt4 book ai didi

reactjs - Material-UI 依赖项 : '' react-tap-event-plugin '' has no exported member ' injectTapEventPlugin'

转载 作者:搜寻专家 更新时间:2023-10-30 21:16:47 25 4
gpt4 key购买 nike

我正在使用 react/typescript/material-ui/webpack。 Material-UI 依赖于 react-tap-event-plugin,我在导入 injectTapEventPlugin 函数时遇到问题,这是我得到的错误:

error TS2305: Module ''react-tap-event-plugin'' has no exported member 'injectTapEventPlugin'.

要为 react-tap-event-plugin 添加定义,我使用了以下命令:

sudo typings install dt~react-tap-event-plugin --save --global --save-dev

index.d.ts 看起来像这样:

declare module 'react-tap-event-plugin'{
interface StrategyOverrides {
shouldRejectClick?: (lastTouchEventTimestamp: Date, clickEventTimestamp: Date) => boolean;
}

var injectTapEventPlugin: (strategyOverrides?: StrategyOverrides) => void;

export = injectTapEventPlugin;
}

我正在尝试使用以下方法在我的应用程序中导入插件:

import {injectTapEventPlugin} from 'react-tap-event-plugin';
injectTapEventPlugin();

知道我遗漏了什么吗?

最佳答案

摘自github项目中的测试文件

// since the export is a function, this is the only actual correct way:
import injectTapEventPluginRequire = require("react-tap-event-plugin");

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/react-tap-event-plugin/react-tap-event-plugin-tests.ts

关于reactjs - Material-UI 依赖项 : '' react-tap-event-plugin '' has no exported member ' injectTapEventPlugin',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37918329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com