闫增涛
2024-02-23 fdfb3ca757ecd6c396632ed276ff354671d3a7e5
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Component({
  relations: {
    '../../c-sidebar/index': {
      type: 'ancestor',
      linked(target) {
        this.parent = target;
      },
    },
  },
 
  externalClasses: ['custom-class'],
  properties: {
    title: String,
    disabled: Boolean,
  },
 
  data: {
    topRightRadius: false,
    bottomRightRadius: false,
  },
 
  methods: {
    setActive(selected) {
      return this.setData({ selected });
    },
    onClick() {
      const { parent } = this;
 
      if (!parent || this.properties.disabled) {
        return;
      }
 
      const index = parent.children.indexOf(this);
 
      parent.setActive(index).then(() => {
        this.triggerEvent('click', index);
        parent.triggerEvent('change', { index });
      });
    },
    setTopRightRadius(val) {
      return this.setData({
        topRightRadius: val,
      });
    },
    setBottomRightRadius(val) {
      return this.setData({
        bottomRightRadius: val,
      });
    },
  },
});