Skip to content

Commit

Permalink
fixed iview#2214
Browse files Browse the repository at this point in the history
  • Loading branch information
icarusion committed Nov 7, 2017
1 parent 6d2b7bc commit 05265be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions examples/routers/breadcrumb.vue
Expand Up @@ -7,8 +7,8 @@
<template>
<div>
<Breadcrumb separator="<b class='demo-breadcrumb-separator'>=></b>">
<Breadcrumb-item href="/">Home4</Breadcrumb-item>
<Breadcrumb-item href="/checkbox" replace>Components</Breadcrumb-item>
<Breadcrumb-item to="/">Home4</Breadcrumb-item>
<Breadcrumb-item :to="{name: 'user', params: { userId: 123 }}">Components</Breadcrumb-item>
<Breadcrumb-item>Breadcrumb</Breadcrumb-item>
</Breadcrumb>
<Breadcrumb separator="">
Expand All @@ -18,7 +18,7 @@
<b style="color: #ff5500;">-></b>
</template>
</Breadcrumb-item>
<Breadcrumb-item href="/components/breadcrumb">
<Breadcrumb-item href="/components/page">
<template>Breadcrumb</template>
<template slot="separator">
<b style="color: #ff5500;">-></b>
Expand Down
12 changes: 8 additions & 4 deletions src/components/breadcrumb/breadcrumb-item.vue
@@ -1,6 +1,6 @@
<template>
<span>
<a v-if="href" :class="linkClasses" @click="handleClick">
<a v-if="to || href" :class="linkClasses" @click="handleClick">
<slot></slot>
</a>
<span v-else :class="linkClasses">
Expand All @@ -13,13 +13,17 @@
</span>
</template>
<script>
// todo 3.0 时废弃 href
const prefixCls = 'ivu-breadcrumb-item';
export default {
name: 'BreadcrumbItem',
props: {
href: {
type: String
type: [Object, String]
},
to: {
type: [Object, String]
},
replace: {
type: Boolean,
Expand Down Expand Up @@ -47,9 +51,9 @@
handleClick () {
const isRoute = this.$router;
if (isRoute) {
this.replace ? this.$router.replace(this.href) : this.$router.push(this.href);
this.replace ? this.$router.replace(this.to || this.href) : this.$router.push(this.to || this.href);
} else {
window.location.href = this.href;
window.location.href = this.to || this.href;
}
}
}
Expand Down

0 comments on commit 05265be

Please sign in to comment.