Blame view

src/TabPane/TabPane.js 869 Bytes
3a3ecabe   Imshann   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  import template from "./TabPane.html";
  
  class TabPane {
      props = { key: Number, tab: String };
  
      state = {
          activeKey: null,
          key: this.props.key,
      };
  
      watch = {
          tab: function (newVal, oldVal) {
              if (newVal !== oldVal) {
                  let item = this.esTabs.state.labels.find(function (item) {
                      return item.key === this.props.key;
                  });
                  if (item) {
                      item.name = newVal;
                  }
              }
          },
      };
  
      template = template;
  
      constructor(esTabs) {
          this.esTabs = esTabs.getContext();
          this.esTabs.state.labels.push({
              name: this.props.tab,
              key: this.props.key,
          });
          this.esTabs.state.childrens.push($scope);
          this.state.activeKey = this.esTabs.state.activeKey;
      }
  }