Commit e77474de9ef341960f0ff5a2804050fec5f0f02a
1 parent
5fe393db
update
Showing
2 changed files
with
21 additions
and
12 deletions
Show diff stats
src/components/cell/cell.vue
| 1 | <template> | 1 | <template> |
| 2 | <div :class="classes" tabindex="0"> | 2 | <div :class="classes" tabindex="0"> |
| 3 | - <a v-if="to" :href="to" class="ivu-cell-link" @click.prevent="handleClick"> | 3 | + <a v-if="to" :href="linkUrl" class="ivu-cell-link" @click.prevent="handleClick"> |
| 4 | <CellItem :title="title" :label="label" :extra="extra"> | 4 | <CellItem :title="title" :label="label" :extra="extra"> |
| 5 | <slot name="icon" slot="icon"></slot> | 5 | <slot name="icon" slot="icon"></slot> |
| 6 | <slot></slot> | 6 | <slot></slot> |
| @@ -24,11 +24,13 @@ | @@ -24,11 +24,13 @@ | ||
| 24 | <script> | 24 | <script> |
| 25 | import CellItem from './cell-item.vue'; | 25 | import CellItem from './cell-item.vue'; |
| 26 | import Icon from '../icon/icon.vue'; | 26 | import Icon from '../icon/icon.vue'; |
| 27 | + import mixinsLink from '../../mixins/link'; | ||
| 27 | 28 | ||
| 28 | const prefixCls = 'ivu-cell'; | 29 | const prefixCls = 'ivu-cell'; |
| 29 | 30 | ||
| 30 | export default { | 31 | export default { |
| 31 | name: 'Cell', | 32 | name: 'Cell', |
| 33 | + mixins: [ mixinsLink ], | ||
| 32 | components: { CellItem, Icon }, | 34 | components: { CellItem, Icon }, |
| 33 | props: { | 35 | props: { |
| 34 | name: { | 36 | name: { |
| @@ -77,17 +79,7 @@ | @@ -77,17 +79,7 @@ | ||
| 77 | [`${prefixCls}-with-link`]: this.to | 79 | [`${prefixCls}-with-link`]: this.to |
| 78 | } | 80 | } |
| 79 | ]; | 81 | ]; |
| 80 | - } | 82 | + }, |
| 81 | }, | 83 | }, |
| 82 | - methods: { | ||
| 83 | - handleClick () { | ||
| 84 | - const isRoute = this.$router; | ||
| 85 | - if (isRoute) { | ||
| 86 | - this.replace ? this.$router.replace(this.to) : this.$router.push(this.to); | ||
| 87 | - } else { | ||
| 88 | - window.location.href = this.to; | ||
| 89 | - } | ||
| 90 | - } | ||
| 91 | - } | ||
| 92 | } | 84 | } |
| 93 | </script> | 85 | </script> |
| 94 | \ No newline at end of file | 86 | \ No newline at end of file |
| 1 | +export default { | ||
| 2 | + computed: { | ||
| 3 | + linkUrl () { | ||
| 4 | + | ||
| 5 | + } | ||
| 6 | + }, | ||
| 7 | + methods: { | ||
| 8 | + handleClick () { | ||
| 9 | + const isRoute = this.$router; | ||
| 10 | + if (isRoute) { | ||
| 11 | + this.replace ? this.$router.replace(this.to) : this.$router.push(this.to); | ||
| 12 | + } else { | ||
| 13 | + window.location.href = this.to; | ||
| 14 | + } | ||
| 15 | + } | ||
| 16 | + } | ||
| 17 | +} | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |