嗨,我是Reactjs的新手。我正在使用fineuploader將文件上傳到server.i想創建FineUploader組件,以便我可以在任何地方使用它。如何在React中使用Fine Uploader js
的package.json
{
"name": "Sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"fine-uploader": "^5.7.1",
"react": "^0.14.6",
"react-dom": "^0.14.6",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
}
}
webpack.config.js
var path = require("path");
module.exports = {
entry: [
'./Components/Main.js'
],
output:{
path:__dirname,
filename:'bundle.js'
},
resolve: {
alias: {
'fine-uploader': path.resolve('node_modules/fine-uploader/fine-uploader')
}
},
module:{
loaders: [
{
test: /fine-uploader\.js/,
loader: 'exports?qq'
}
],
loaders:[{
test: /\.jsx?$/,
exclude:/node_modules/,
loader:'babel',
query:{
presets: ['react']
}
}]
}
};
FineUploader.js
import React from 'react';
import qq from 'fine-uploader/fine-uploader';
class FineUploader extends React.Component {
constructor (props) {
super(props)
}
componentDidMount() {
const fu = new qq.FineUploaderBasic({
button: this.refs.fu
})
}
render() {
return <div ref='fu'>Upload!</div>
}
}
export default FineUploader;
Main.js
import React from 'react';
import ReactDOM from 'react-dom';
import FineUploader from './FineUploader.js';
var MainContent = React.createClass({
render:function(){
return (
<div>
<FineUploader />
</div>
);
}
});
ReactDOM.render(<MainContent />,document.getElementById('container'));
當我跑我得到下面的錯誤 遺漏的類型錯誤的應用:_fineUploader2.default.FineUploaderBasic是不是構造
我不力沒有什麼我做錯了,PLZ有人指導我
的可能的複製[精細上傳者的WebPack&ES6(http://stackoverflow.com/questions/36185540/fine-uploader-with-webpack-es6) –
陣營精細上傳剛剛發佈:HTTPS ://github.com/FineUploader/react-fine-uploader –