Commit c736b0f1e04f25ec3915e30683e68095be1098fc
1 parent
7fe58637
fix #4189
Showing
2 changed files
with
69 additions
and
49 deletions
Show diff stats
examples/routers/cascader.vue
| 1 | 1 | <template> |
| 2 | - <Cascader :data="data4" :load-data="loadData"></Cascader> | |
| 2 | + <div> | |
| 3 | + <Row> | |
| 4 | + <i-col span="18"> | |
| 5 | + <i-button v-on:click="setValue">setValue</i-button> | |
| 6 | + </i-col> | |
| 7 | + <i-col span="4"> | |
| 8 | + <Cascader :data="data" v-model="value1" transfer></Cascader> | |
| 9 | + </i-col> | |
| 10 | + </Row> | |
| 11 | + </div> | |
| 3 | 12 | </template> |
| 4 | 13 | <script> |
| 5 | 14 | export default { |
| 6 | 15 | data () { |
| 7 | 16 | 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 | - ] | |
| 17 | + value1: [], | |
| 18 | + data: [{ | |
| 19 | + value: '9ecec83c-cf6b-4cfe-aa75-eb3510875331', | |
| 20 | + label: '北京', | |
| 21 | + children: [{ | |
| 22 | + value: 'a873a9bd-7d75-4f46-9369-4d25a1feb13c', | |
| 23 | + label: '故宫' | |
| 24 | + }, { | |
| 25 | + value: 'tiantan', | |
| 26 | + label: '天坛' | |
| 27 | + }, { | |
| 28 | + value: 'wangfujing', | |
| 29 | + label: '王府井' | |
| 30 | + }] | |
| 31 | + }, { | |
| 32 | + value: 'ca7c0fbc-728d-42e8-b111-f5f73cf9171b', | |
| 33 | + label: '江苏', | |
| 34 | + children: [{ | |
| 35 | + value: 'a89d891b-5c50-44c0-87b4-d4f934edc921', | |
| 36 | + label: '南京', | |
| 37 | + children: [{ | |
| 38 | + value: '44736384-0ede-41ba-bf7a-59c84241851a', | |
| 39 | + label: '夫子庙中国第一庙来自南京', | |
| 40 | + children:[{ | |
| 41 | + value: '44736384-0ede-41ba-bf7a-59c84241851c', | |
| 42 | + label:'自定义产品系统来自黑龙江地区' | |
| 43 | + }] | |
| 44 | + }] | |
| 45 | + }, { | |
| 46 | + value: 'suzhou', | |
| 47 | + label: '苏州', | |
| 48 | + children: [{ | |
| 49 | + value: 'zhuozhengyuan', | |
| 50 | + label: '拙政园', | |
| 51 | + }, { | |
| 52 | + value: 'shizilin', | |
| 53 | + label: '狮子林', | |
| 54 | + }] | |
| 55 | + }], | |
| 56 | + }] | |
| 22 | 57 | } |
| 23 | 58 | }, |
| 24 | 59 | methods: { |
| 25 | - loadData (item, callback) { | |
| 26 | - item.loading = true; | |
| 27 | - setTimeout(() => { | |
| 28 | - if (item.value === 'beijing') { | |
| 29 | - item.children = [ | |
| 30 | - { | |
| 31 | - value: 'talkingdata', | |
| 32 | - label: 'TalkingData' | |
| 33 | - }, | |
| 34 | - { | |
| 35 | - value: 'baidu', | |
| 36 | - label: '百度' | |
| 37 | - }, | |
| 38 | - { | |
| 39 | - value: 'sina', | |
| 40 | - label: '新浪' | |
| 41 | - } | |
| 42 | - ]; | |
| 43 | - } else if (item.value === 'hangzhou') { | |
| 44 | - item.children = [ | |
| 45 | - { | |
| 46 | - value: 'ali', | |
| 47 | - label: '阿里巴巴' | |
| 48 | - }, | |
| 49 | - { | |
| 50 | - value: '163', | |
| 51 | - label: '网易' | |
| 52 | - } | |
| 53 | - ]; | |
| 54 | - } | |
| 55 | - item.loading = false; | |
| 56 | - callback(); | |
| 57 | - }, 1000); | |
| 60 | + setValue() { | |
| 61 | + var v = "ca7c0fbc-728d-42e8-b111-f5f73cf9171b,a89d891b-5c50-44c0-87b4-d4f934edc921,44736384-0ede-41ba-bf7a-59c84241851a"; | |
| 62 | + var x = v.split(',') | |
| 63 | + var x1 = x[0].toString(); | |
| 64 | + var x2 = x[1].toString(); | |
| 65 | + var x3 = x[2].toString(); | |
| 66 | + | |
| 67 | + this.value1 = x; | |
| 58 | 68 | } |
| 69 | + }, | |
| 70 | + mounted () { | |
| 71 | + | |
| 59 | 72 | } |
| 60 | 73 | } |
| 61 | 74 | </script> |
| 75 | +<style> | |
| 76 | + | |
| 77 | +</style> | |
| 62 | 78 | \ No newline at end of file | ... | ... |
src/components/cascader/caspanel.vue
| ... | ... | @@ -59,8 +59,8 @@ |
| 59 | 59 | handleTriggerItem (item, fromInit = false, fromUser = false) { |
| 60 | 60 | if (item.disabled) return; |
| 61 | 61 | |
| 62 | + const cascader = findComponentUpward(this, 'Cascader'); | |
| 62 | 63 | if (item.loading !== undefined && !item.children.length) { |
| 63 | - const cascader = findComponentUpward(this, 'Cascader'); | |
| 64 | 64 | if (cascader && cascader.loadData) { |
| 65 | 65 | cascader.loadData(item, () => { |
| 66 | 66 | // todo |
| ... | ... | @@ -110,6 +110,10 @@ |
| 110 | 110 | fromInit: fromInit |
| 111 | 111 | }); |
| 112 | 112 | } |
| 113 | + | |
| 114 | + if (cascader) { | |
| 115 | + cascader.$refs.drop.update(); | |
| 116 | + } | |
| 113 | 117 | }, |
| 114 | 118 | updateResult (item) { |
| 115 | 119 | this.result = [this.tmpItem].concat(item); | ... | ... |