Commit cb6418ac5ed418fd169a3b6e92098318b4ac77a0
1 parent
8409abb8
fixed #721
Showing
3 changed files
with
60 additions
and
21 deletions
Show diff stats
examples/routers/checkbox.vue
examples/routers/dropdown.vue
| 1 | +<!--<template>--> | |
| 2 | + <!--<Row>--> | |
| 3 | + <!--<i-col span="8">--> | |
| 4 | + <!--<Card>--> | |
| 5 | + <!--<Dropdown @on-click="handleClick">--> | |
| 6 | + <!--<a href="javascript:void(0)">--> | |
| 7 | + <!--下拉菜单--> | |
| 8 | + <!--<Icon type="arrow-down-b"></Icon>--> | |
| 9 | + <!--</a>--> | |
| 10 | + <!--<Dropdown-menu slot="list">--> | |
| 11 | + <!--<Dropdown-item name="1">驴打滚</Dropdown-item>--> | |
| 12 | + <!--<Dropdown-item name="2">炸酱面</Dropdown-item>--> | |
| 13 | + <!--<Dropdown-item name="3" disabled>豆汁儿</Dropdown-item>--> | |
| 14 | + <!--<Dropdown-item name="4">冰糖葫芦</Dropdown-item>--> | |
| 15 | + <!--<Dropdown-item name="5" divided>北京烤鸭</Dropdown-item>--> | |
| 16 | + <!--</Dropdown-menu>--> | |
| 17 | + <!--</Dropdown>--> | |
| 18 | + <!--</Card>--> | |
| 19 | + <!--</i-col>--> | |
| 20 | + <!--</Row>--> | |
| 21 | +<!--</template>--> | |
| 22 | +<!--<script>--> | |
| 23 | + <!--export default {--> | |
| 24 | + <!--methods: {--> | |
| 25 | + <!--handleClick (val) {--> | |
| 26 | + <!--console.log(val)--> | |
| 27 | + <!--}--> | |
| 28 | + <!--}--> | |
| 29 | + <!--}--> | |
| 30 | +<!--</script>--> | |
| 31 | + | |
| 1 | 32 | <template> |
| 2 | - <div> | |
| 3 | - <Dropdown @on-click="handleClick"> | |
| 4 | - <a href="javascript:void(0)"> | |
| 5 | - 下拉菜单 | |
| 6 | - <Icon type="arrow-down-b"></Icon> | |
| 7 | - </a> | |
| 8 | - <Dropdown-menu slot="list"> | |
| 9 | - <Dropdown-item name="1">驴打滚</Dropdown-item> | |
| 10 | - <Dropdown-item name="2">炸酱面</Dropdown-item> | |
| 11 | - <Dropdown-item name="3" disabled>豆汁儿</Dropdown-item> | |
| 12 | - <Dropdown-item name="4">冰糖葫芦</Dropdown-item> | |
| 13 | - <Dropdown-item name="5" divided>北京烤鸭</Dropdown-item> | |
| 14 | - </Dropdown-menu> | |
| 15 | - </Dropdown> | |
| 16 | - </div> | |
| 33 | + <Table border :context="self" :columns="columns7" :data="data6"></Table> | |
| 17 | 34 | </template> |
| 18 | 35 | <script> |
| 19 | 36 | export default { |
| 37 | + data () { | |
| 38 | + return { | |
| 39 | + self: this, | |
| 40 | + columns7: [ | |
| 41 | + { | |
| 42 | + title: '姓名', | |
| 43 | + key: 'name', | |
| 44 | + render (row, column, index) { | |
| 45 | + return `<Dropdown @on-click="change"><a href="javascript:void(0)">下拉菜单<Icon type="arrow-down-b"></Icon></a><Dropdown-menu slot="list"><Dropdown-item name="1">驴打滚</Dropdown-item><Dropdown-item name="2">炸酱面</Dropdown-item><Dropdown-item disabled name="3">豆汁儿</Dropdown-item><Dropdown-item>冰糖葫芦</Dropdown-item><Dropdown-item divided>北京烤鸭</Dropdown-item></Dropdown-menu></Dropdown>`; | |
| 46 | + } | |
| 47 | + } | |
| 48 | + ], | |
| 49 | + data6: [ | |
| 50 | + { | |
| 51 | + name: '王小明', | |
| 52 | + age: 18, | |
| 53 | + address: '北京市朝阳区芍药居' | |
| 54 | + } | |
| 55 | + ] | |
| 56 | + } | |
| 57 | + }, | |
| 20 | 58 | methods: { |
| 21 | - handleClick (val) { | |
| 22 | - console.log(val) | |
| 59 | + change (s) { | |
| 60 | + console.log(s) | |
| 23 | 61 | } |
| 24 | 62 | } |
| 25 | 63 | } | ... | ... |
src/components/dropdown/dropdown.vue
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | <script> |
| 14 | 14 | import Drop from '../select/dropdown.vue'; |
| 15 | 15 | import clickoutside from '../../directives/clickoutside'; |
| 16 | - import { oneOf } from '../../utils/assist'; | |
| 16 | + import { oneOf, findComponentUpward } from '../../utils/assist'; | |
| 17 | 17 | |
| 18 | 18 | const prefixCls = 'ivu-dropdown'; |
| 19 | 19 | |
| ... | ... | @@ -99,8 +99,9 @@ |
| 99 | 99 | this.currentVisible = false; |
| 100 | 100 | }, |
| 101 | 101 | hasParent () { |
| 102 | - const $parent = this.$parent.$parent.$parent; | |
| 103 | - if ($parent && $parent.$options.name === 'Dropdown') { | |
| 102 | +// const $parent = this.$parent.$parent.$parent; | |
| 103 | + const $parent = findComponentUpward(this, 'Dropdown'); | |
| 104 | + if ($parent) { | |
| 104 | 105 | return $parent; |
| 105 | 106 | } else { |
| 106 | 107 | return false; | ... | ... |