Commit e129a2508c020a648ca7282d318e4bfcf2ebd7e4
Merge branch '2.0' of https://github.com/iview/iview into 2.0
Showing
2 changed files
with
13 additions
and
4 deletions
Show diff stats
examples/routers/table.vue
| 1 | 1 | <template> |
| 2 | - <Table border :columns="columns5" :data="data5"></Table> | |
| 2 | + <Table border :columns="columns5" :data="data5" @on-select="onSelect(true)" @on-select-cancel="onSelect(false)"></Table> | |
| 3 | 3 | </template> |
| 4 | 4 | <script> |
| 5 | 5 | import etable from '../components/table.vue'; |
| ... | ... | @@ -9,6 +9,11 @@ |
| 9 | 9 | return { |
| 10 | 10 | columns5: [ |
| 11 | 11 | { |
| 12 | + type: 'selection', | |
| 13 | + width: 60, | |
| 14 | + align: 'center' | |
| 15 | + }, | |
| 16 | + { | |
| 12 | 17 | type: 'expand', |
| 13 | 18 | render: (h) => { |
| 14 | 19 | console.log('______hover______'); |
| ... | ... | @@ -73,6 +78,12 @@ |
| 73 | 78 | }, |
| 74 | 79 | ] |
| 75 | 80 | } |
| 81 | + }, | |
| 82 | + | |
| 83 | + methods: { | |
| 84 | + onSelect (value) { | |
| 85 | + window.alert(value); | |
| 86 | + } | |
| 76 | 87 | } |
| 77 | 88 | } |
| 78 | 89 | </script> | ... | ... |
src/components/table/table.vue
| ... | ... | @@ -404,9 +404,7 @@ |
| 404 | 404 | this.objData[_index]._isChecked = status; |
| 405 | 405 | |
| 406 | 406 | const selection = this.getSelection(); |
| 407 | - if (status) { | |
| 408 | - this.$emit('on-select', selection, JSON.parse(JSON.stringify(this.data[_index]))); | |
| 409 | - } | |
| 407 | + this.$emit(status ? 'on-select' : 'on-select-cancel', selection, JSON.parse(JSON.stringify(this.data[_index]))); | |
| 410 | 408 | this.$emit('on-selection-change', selection); |
| 411 | 409 | }, |
| 412 | 410 | toggleExpand (_index) { | ... | ... |