我尝试使用react组件包在数据表中显示CSV,但发现active-table-react。我使用CRA和typescript模板创建了一个React应用程序,其中我添加了npm包,但在导入组件并运行npm start
后,我收到以下错误:
ERROR in ./node_modules/active-table/dist/activeTable.js 32:0-54
Module not found: Error: Can't resolve './activeTableStyle' in '/home/user/Projects/react-table-demo/node_modules/active-table/dist'
Did you mean 'activeTableStyle.js'?
BREAKING CHANGE: The request './activeTableStyle' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
我试过使用不同版本的node和react,但是没有效果。然而,示例沙箱shown in the docs运行良好,尽管我有完全相同的配置。下面是我的代码用于比较。
// App.tsx
import React, { useState } from 'react';
import './App.css';
import { ActiveTable } from 'active-table-react';
function App() {
const content = [
["Planet", "Diameter", "Mass"],
["Earth", 12756, 5.97],
["Mars", 6792, 0.642]
];
return (
<div className="App">
<ActiveTable
content={content}
headerStyles={{ default: { backgroundColor: "#d6d6d630" } }}
/>
</div>
);
}
export default App;
我错过了什么?任何帮助都将不胜感激。Active table documentationActive table source
1条答案
按热度按时间b09cbbtk1#
在
rules
中webpack.config.js中添加: