Blame view

src/TabPane/TabPane.js 883 Bytes
3a3ecabe   Imshann   init
1
2
3
4
5
6
7
8
9
10
11
12
13
  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) {
81f8a467   Imshann   调整组件前缀
14
                  let item = this.antdTabs.state.labels.find(function (item) {
3a3ecabe   Imshann   init
15
16
17
18
19
20
21
22
23
24
25
                      return item.key === this.props.key;
                  });
                  if (item) {
                      item.name = newVal;
                  }
              }
          },
      };
  
      template = template;
  
81f8a467   Imshann   调整组件前缀
26
27
28
      constructor(antdTabs) {
          this.antdTabs = antdTabs.getContext();
          this.antdTabs.state.labels.push({
3a3ecabe   Imshann   init
29
30
31
              name: this.props.tab,
              key: this.props.key,
          });
81f8a467   Imshann   调整组件前缀
32
33
          this.antdTabs.state.childrens.push($scope);
          this.state.activeKey = this.antdTabs.state.activeKey;
3a3ecabe   Imshann   init
34
35
      }
  }