Blame view

src/Button/Button.js 1.46 KB
3a3ecabe   Imshann   init
1
2
3
4
5
6
7
  import template from "./Button.html";
  import style from "antd/lib/button/style/index.css";
  
  class Button {
      
      useModules = ["esNgAntd"];
  
3a3ecabe   Imshann   init
8
9
10
11
12
      state = {
          disabled: null,
          className: "",
      };
  
3a3ecabe   Imshann   init
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
      watch = {
          loading:  (newVal)=> {
              if (newVal !== undefined) {
                  if (newVal === "true") {
                      this.state.className += " ant-btn-loading";
                  } else {
                      this.state.className = this.state.className.replace(
                          " ant-btn-loading",
                          ""
                      );
                  }
              }
          },
      };
  
50f4289a   Imshann   优化Form组件
28
      constructor($element) {
3a3ecabe   Imshann   init
29
30
31
          esNgAntd.createStyle("ant-btn", style);
  
          let className = ["ant-btn"];
3a3ecabe   Imshann   init
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
          if (this.props.type) {
              className.push("ant-btn-" + this.props.type);
          }
          if (this.props.size && ["lg", "sm", "xs"].includes(this.props.size)) {
              className.push("ant-btn-" + this.props.size);
          }
          if (this.props.ghost) {
              className.push("ant-btn-background-ghost");
          }
          this.state.className = className.join(" ");
  
          if (this.props.htmlType) {
              $element[0].setAttribute("type", this.props.htmlType)
          }
      }
2092c4d5   Imshann   优化
47
48
49
50
  
      render() {
          return template;
      }
3a3ecabe   Imshann   init
51
  }
2092c4d5   Imshann   优化
52
53
54
55
56
57
58
59
  
  Button.propTypes = {
      type: PropTypes.string,
      size: PropTypes.string,
      htmlType: PropTypes.string,
      ghost: PropTypes.boolean,
      loading: PropTypes.boolean,
  };