1 | import React from "react";
|
2 | import { Button } from "antd";
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export default function InputFileBtn({ onChange }) {
|
10 | const _onChange = e => {
|
11 | const file = e.target.files[0];
|
12 | const reader = new FileReader();
|
13 | reader.readAsDataURL(file);
|
14 | reader.onload = function() {
|
15 | onChange(this.result);
|
16 | };
|
17 | };
|
18 |
|
19 | return (
|
20 | <label>
|
21 | <input
|
22 | type="file"
|
23 | style={{ opacity: 0, width: "1px" }}
|
24 | onChange={_onChange}
|
25 | />
|
26 | <span style={{ cursor: "pointer", color: "#1944bb" }}>上传</span>
|
27 | </label>
|
28 | );
|
29 | }
|