update
This commit is contained in:
parent
5fe393db5c
commit
e77474de9e
2 changed files with 21 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div :class="classes" tabindex="0">
|
||||
<a v-if="to" :href="to" class="ivu-cell-link" @click.prevent="handleClick">
|
||||
<a v-if="to" :href="linkUrl" class="ivu-cell-link" @click.prevent="handleClick">
|
||||
<CellItem :title="title" :label="label" :extra="extra">
|
||||
<slot name="icon" slot="icon"></slot>
|
||||
<slot></slot>
|
||||
|
@ -24,11 +24,13 @@
|
|||
<script>
|
||||
import CellItem from './cell-item.vue';
|
||||
import Icon from '../icon/icon.vue';
|
||||
import mixinsLink from '../../mixins/link';
|
||||
|
||||
const prefixCls = 'ivu-cell';
|
||||
|
||||
export default {
|
||||
name: 'Cell',
|
||||
mixins: [ mixinsLink ],
|
||||
components: { CellItem, Icon },
|
||||
props: {
|
||||
name: {
|
||||
|
@ -77,17 +79,7 @@
|
|||
[`${prefixCls}-with-link`]: this.to
|
||||
}
|
||||
];
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleClick () {
|
||||
const isRoute = this.$router;
|
||||
if (isRoute) {
|
||||
this.replace ? this.$router.replace(this.to) : this.$router.push(this.to);
|
||||
} else {
|
||||
window.location.href = this.to;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
17
src/mixins/link.js
Normal file
17
src/mixins/link.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
export default {
|
||||
computed: {
|
||||
linkUrl () {
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick () {
|
||||
const isRoute = this.$router;
|
||||
if (isRoute) {
|
||||
this.replace ? this.$router.replace(this.to) : this.$router.push(this.to);
|
||||
} else {
|
||||
window.location.href = this.to;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue