3a3ecabe
Imshann
init
|
1
2
3
4
|
import template from "./Textarea.html";
import style from "antd/lib/input/style/index.css";
class Textarea {
|
91af8307
Imshann
优化Textarea组件
|
5
|
useModules = ["esNgAntd"];
|
3a3ecabe
Imshann
init
|
6
7
8
9
10
11
12
|
state = {
value: this.props.value,
count: 0,
maxLength: this.props.maxLength || "off",
};
|
91af8307
Imshann
优化Textarea组件
|
13
14
15
|
constructor() {
esNgAntd.createStyle("ant-input", style);
}
|
3a3ecabe
Imshann
init
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
handleKeyup(event) {
if (!this.event) {
this.event = event;
}
if (this.state.maxLength === "off") {
return;
}
let target = event.target;
this.state.count = target.value.length;
}
handleClick(event) {
if (!this.event) {
this.event = event;
}
}
handleChange() {
|
3a3ecabe
Imshann
init
|
35
|
this.props.onChange({
|
91af8307
Imshann
优化Textarea组件
|
36
37
|
event: this.event,
});
|
3a3ecabe
Imshann
init
|
38
39
|
}
|
91af8307
Imshann
优化Textarea组件
|
40
41
|
render() {
return template;
|
3a3ecabe
Imshann
init
|
42
43
|
}
}
|
91af8307
Imshann
优化Textarea组件
|
44
45
46
47
48
49
50
51
|
Textarea.propTypes = {
value: PropTypes.string,
placeholder: PropTypes.string,
showCount: PropTypes.boolean,
maxLength: PropTypes.number,
onChange: PropTypes.function,
};
|