Blame view

examples/routers/cascader.vue 3.94 KB
47a7f21d   梁灏   support Cascader
1
  <template>
f7ffdac5   梁灏   Cascader support ...
2
3
4
      <Row>
          <i-col span="4">
              <Button @click="handleLoad">load</Button>
7ec0b533   梁灏   Cascader support ...
5
              {{ v1 }}
f7ffdac5   梁灏   Cascader support ...
6
          </i-col>
7ec0b533   梁灏   Cascader support ...
7
          <i-col span="4">
5a9a12cd   梁灏   update Cascader
8
9
              <Cascader :data="data3" filterable v-model="v1"></Cascader>
              <!--<Cascader :data="data2" filterable v-model="v1" :loadData="loadData"></Cascader>-->
f7ffdac5   梁灏   Cascader support ...
10
11
          </i-col>
      </Row>
0a48ac45   梁灏   Input add readonl...
12
13
  </template>
  <script>
0a48ac45   梁灏   Input add readonl...
14
      export default {
0a48ac45   梁灏   Input add readonl...
15
16
          data () {
              return {
f7ffdac5   梁灏   Cascader support ...
17
                  v1: [],
7ec0b533   梁灏   Cascader support ...
18
19
20
21
22
23
24
25
26
27
                  data2: [
                      {
                          value: 'zhejiang',
                          label: '浙江',
                          children: [],
                          loading: false
                      },
                      {
                          value: 'jiangsu',
                          label: '江苏',
65b41a2d   梁灏   fixed #635
28
                          children: [{
7ec0b533   梁灏   Cascader support ...
29
30
31
32
33
34
                              value: 'nanjing',
                              label: '南京',
                              children: [{
                                  value: 'zhonghuamen',
                                  label: '中华门'
                              }]
65b41a2d   梁灏   fixed #635
35
                          }]
7ec0b533   梁灏   Cascader support ...
36
37
                      }
                  ],
5a9a12cd   梁灏   update Cascader
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
                  data3: [{
                      value: 'beijing',
                      label: '北京',
                      children: [
                          {
                              value: 'gugong',
                              label: '故宫'
                          },
                          {
                              value: 'tiantan',
                              label: '天坛'
                          },
                          {
                              value: 'wangfujing',
                              label: '王府井'
                          }
                      ]
                  }, {
                      value: 'jiangsu',
                      label: '江苏',
                      children: [
                          {
                              value: 'nanjing',
                              label: '南京',
                              children: [
                                  {
                                      value: 'fuzimiao',
                                      label: '夫子庙',
                                  }
                              ]
                          },
                          {
                              value: 'suzhou',
                              label: '苏州',
                              children: [
                                  {
7ec0b533   梁灏   Cascader support ...
74
                                      disabled: true,
5a9a12cd   梁灏   update Cascader
75
76
77
78
79
80
81
82
83
84
                                      value: 'zhuozhengyuan',
                                      label: '拙政园',
                                  },
                                  {
                                      value: 'shizilin',
                                      label: '狮子林',
                                  }
                              ]
                          }
                      ],
65b41a2d   梁灏   fixed #635
85
86
                  }]
              }
f7ffdac5   梁灏   Cascader support ...
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
          },
          methods: {
              handleLoad () {
                  this.data2[0].loading = !this.data2[0].loading;
              },
              loadData (item, cb) {
                  item.loading = true;
                  setTimeout(() => {
                      if (item.value === 'zhejiang') {
                          item.children = [
                              {
                                  value: 'hangzhou',
                                  label: '杭州',
                                  loading: false,
                                  children: []
                              }
                          ];
                      } else if (item.value === 'hangzhou') {
                          item.children = [
                              {
                                  value: 'ali',
                                  label: '阿里巴巴'
                              }
                          ];
                      }
                      item.loading = false;
                      cb();
                  }, 1000);
              }
0a48ac45   梁灏   Input add readonl...
116
117
          }
      }
c9433dcc   梁灏   optimize Timeline...
118
  </script>