Commit f3893b007d801496ded30070f9e21883b012e27e

Authored by 梁灏
1 parent 1d83a8aa

update

Showing 1 changed file with 105 additions and 49 deletions   Show diff stats
examples/routers/cascader.vue
1 1 <template>
2   - <Cascader :data="data4" :load-data="loadData"></Cascader>
  2 + <div style="margin: 100px;width: 200px;">
  3 + {{ value }}
  4 + <Cascader v-model="value" :data="data" change-on-select></Cascader>
  5 + <Button @click="change">change</Button>
  6 + </div>
3 7 </template>
4 8 <script>
5 9 export default {
6 10 data () {
7 11 return {
8   - data4: [
9   - {
10   - value: 'beijing',
11   - label: '北京',
12   - children: [],
13   - loading: false
14   - },
15   - {
16   - value: 'hangzhou',
17   - label: '杭州',
18   - children: [],
19   - loading:false
20   - }
21   - ]
  12 + value: [],
  13 + data: [{
  14 + value: 'beijing',
  15 + label: '北京',
  16 + children: [
  17 + {
  18 + value: 'gugong',
  19 + label: '故宫'
  20 + },
  21 + {
  22 + value: 'tiantan',
  23 + label: '天坛'
  24 + },
  25 + {
  26 + value: 'wangfujing',
  27 + label: '王府井'
  28 + }
  29 + ]
  30 + }, {
  31 + value: 'jiangsu',
  32 + label: '江苏',
  33 + children: [
  34 + {
  35 + value: 'nanjing',
  36 + label: '南京',
  37 + children: [
  38 + {
  39 + value: 'fuzimiao',
  40 + label: '夫子庙',
  41 + }
  42 + ]
  43 + },
  44 + {
  45 + value: 'suzhou',
  46 + label: '苏州',
  47 + children: [
  48 + {
  49 + value: 'zhuozhengyuan',
  50 + label: '拙政园',
  51 + },
  52 + {
  53 + value: 'shizilin',
  54 + label: '狮子林',
  55 + }
  56 + ]
  57 + }
  58 + ],
  59 + }]
22 60 }
23 61 },
24 62 methods: {
25   - loadData (item, callback) {
26   - item.loading = true;
27   - setTimeout(() => {
28   - console.log(1)
29   - if (item.value === 'beijing') {
30   - item.children = [
31   -// {
32   -// value: 'talkingdata',
33   -// label: 'TalkingData'
34   -// },
35   -// {
36   -// value: 'baidu',
37   -// label: '百度'
38   -// },
39   -// {
40   -// value: 'sina',
41   -// label: '新浪'
42   -// }
43   - ];
44   - } else if (item.value === 'hangzhou') {
45   - item.children = [
46   - {
47   - value: 'ali',
48   - label: '阿里巴巴'
49   - },
50   - {
51   - value: '163',
52   - label: '网易'
53   - }
54   - ];
55   - }
56   - item.loading = false;
57   - callback();
58   - }, 1000);
  63 + change () {
  64 + this.data = [{
  65 + value: 'beijing2',
  66 + label: '北京',
  67 + children: [
  68 + {
  69 + value: 'gugong2',
  70 + label: '故宫'
  71 + },
  72 + {
  73 + value: 'tiantan2',
  74 + label: '天坛'
  75 + },
  76 + {
  77 + value: 'wangfujing2',
  78 + label: '王府井'
  79 + }
  80 + ]
  81 + }, {
  82 + value: 'jiangsu2',
  83 + label: '江苏',
  84 + children: [
  85 + {
  86 + value: 'nanjing2',
  87 + label: '南京',
  88 + children: [
  89 + {
  90 + value: 'fuzimiao2',
  91 + label: '夫子庙',
  92 + }
  93 + ]
  94 + },
  95 + {
  96 + value: 'suzhou2',
  97 + label: '苏州',
  98 + children: [
  99 + {
  100 + value: 'zhuozhengyuan2',
  101 + label: '拙政园',
  102 + },
  103 + {
  104 + value: 'shizilin2',
  105 + label: '狮子林',
  106 + }
  107 + ]
  108 + }
  109 + ],
  110 + }];
  111 +
  112 + this.$nextTick(() => {
  113 + this.value = ['beijing2', 'tiantan2'];
  114 + });
59 115 }
60 116 }
61 117 }
... ...