Blame view

examples/routers/tree.vue 1.92 KB
89f2ba8b   梁灏   init Tree component
1
  <template>
6ed0cd73   梁灏   update Tree demo
2
3
4
5
6
      <div>
          <Tree :data="baseData" show-checkbox></Tree>
          <Button @click="handleAdd">add</Button>
          <Button @click="handleUpdate">update</Button>
      </div>
89f2ba8b   梁灏   init Tree component
7
8
9
  </template>
  <script>
      export default {
e6c0b158   梁灏   update
10
          data () {
e81207a2   梁灏   update Tree
11
              return {
6ed0cd73   梁灏   update Tree demo
12
                  baseData: [
75c32d5f   梁灏   rebuild Tree
13
                      {
6ed0cd73   梁灏   update Tree demo
14
15
                          expand: true,
                          title: 'parent 1',
69a10b78   梁灏   fixed #787
16
17
                          children: [
                              {
6ed0cd73   梁灏   update Tree demo
18
19
20
                                  title: 'parent 1-0',
                                  expand: true,
                                  disabled: true,
69a10b78   梁灏   fixed #787
21
22
                                  children: [
                                      {
6ed0cd73   梁灏   update Tree demo
23
24
                                          title: 'leaf',
                                          disableCheckbox: true
69a10b78   梁灏   fixed #787
25
26
                                      },
                                      {
6ed0cd73   梁灏   update Tree demo
27
                                          title: 'leaf',
69a10b78   梁灏   fixed #787
28
29
                                      }
                                  ]
69a10b78   梁灏   fixed #787
30
31
                              },
                              {
6ed0cd73   梁灏   update Tree demo
32
33
34
35
36
37
38
39
                                  title: 'parent 1-1',
                                  expand: true,
                                  checked: true,
                                  children: [
                                      {
                                          title: '<span style="color: red">leaf</span>',
                                      }
                                  ]
69a10b78   梁灏   fixed #787
40
41
                              }
                          ]
c8157442   梁灏   fixed #499
42
                      }
75c32d5f   梁灏   rebuild Tree
43
                  ]
e81207a2   梁灏   update Tree
44
              }
9d79a51f   梁灏   update Tree
45
46
          },
          methods: {
6ed0cd73   梁灏   update Tree demo
47
48
49
50
51
52
53
54
55
56
57
              handleAdd () {
                  this.baseData.push(
                      {
                          title: 'test name',
                          checked: true
                      }
                  )
              },
              handleUpdate () {
                  this.$set(this.baseData[0].children[0], 'disabled', false);
              }
e81207a2   梁灏   update Tree
58
59
60
          }
      }
  </script>