如何将 uploadcare 导入 react.js 项目?
我的进口部分看起来像这样
// main imports
import React from 'react';
import {render} from 'react-dom';
import { Router, Route, hashHistory } from 'react-router'
import jQuery from '../scripts/jquery-1.8.3.min.js'
import uploadcare from '../lib/uploadcare.min.js'
然后我想像这样使用uploadcare(通过javascript API):
onAddPhotosClick: function() {
console.log("++ add photos");
uploadcare.openDialog(null, {
publicKey: "xxxxxxxxxxxx",
imagesOnly: true,
tabs: "file url facebook gdrive dropbox instagram evernote flickr skydrive"
});
},
我的代码到达 openDialog 行,然后抛出此错误:
:8081/static/react_build/bundle.js:86 Uncaught TypeError: _uploadcareMin2.default.openDialog is not a function
早些时候,在页面加载期间,我的控制台记录:
Global public key not set. Uploads may not work!
Add this to the <head> tag to set your key:
<script>
UPLOADCARE_PUBLIC_KEY = 'your_public_key';
</script>
:8081/static/react_build/bundle.js:85 ++ add photos
我收到上面这条棕色警告消息的事实(我可以接受,因为我希望直接通过 javascript API 设置公钥)让我认为 uploadcare.js 文件已正确包含,但 uploadCareMin2 错误让我认为我没有完全正确地导入它。
TL;博士; 如何将 uploadcare Javascript API 导入 react.js 项目?
感谢您的任何帮助。