javascript - react-simple-file-upload:尝试导入错误
问题描述
我正在尝试使用 Heroku 的新插件:react-simple-file-upload。文献上说要安装“npm install react-simple-file-upload”,然后通过以下方法导入:
import { SimpleFileUpload } from 'react-simple-file-upload'
<SimpleFileUpload
apiKey="..."
onSuccess={handleFile}
/>
function handleFile(url){
console.log('The URL of the file is ' + url)
}
我已经非常准确地遵循了这一点,但不断收到错误消息:
Attempted import error: 'SimpleFileUpload' is not exported from 'react-simple-file-upload'.
console.<computed> @ index.js:1375
我的代码如下所示:
import React from "react";
import { SimpleFileUpload } from 'react-simple-file-upload';
const About = () => (
<div>
<SimpleFileUpload
apiKey="d0a36142ceb56a2c9295eac2feecc8ce"
onSuccess={handleFile}
/>
<h1 className="title is-1">Work in Progress</h1>
<p>
This site is a work in progress as of December 25th, 2020.
</p>
</div>
);
export default About;
解决方案
这是蹩脚的文档。这是默认导出。这应该可以解决问题。
import SimpleFileUpload from 'react-simple-file-upload'
请参阅此处的代码。
https://github.com/pixelplicity/react-simple-file-upload/blob/master/src/index.js
推荐阅读
- reactjs - location.search 的更改不会触发重新渲染
- swift - 想在 NStableview 中打开一个 plist
- python - 过滤掉熊猫数据框中的重复数据
- sql - 可以将 numpy 矩阵转换为数据库表吗?
- python - 访问行 [0] 时读取 CSV 文件会出现 IndexError
- javascript - 使用 jquery 加载时 Highcharts “单击”范围,或加载时 addSeries
- android - 安卓应用和服务器之间的安全验证过程
- storage - 编译solidity合约后,我收到的数据位置必须是“存储”或“内存”错误
- c++ - MediaFoundation + VP8 + 颜色格式
- unity3d - unity 相机跟随滚动箱