Commit 05265beef7670ae28a5fb98338d43f73f6ac0f28

Authored by 梁灏
1 parent 6d2b7bcb

fixed #2214

examples/routers/breadcrumb.vue
@@ -7,8 +7,8 @@ @@ -7,8 +7,8 @@
7 <template> 7 <template>
8 <div> 8 <div>
9 <Breadcrumb separator="<b class='demo-breadcrumb-separator'>=></b>"> 9 <Breadcrumb separator="<b class='demo-breadcrumb-separator'>=></b>">
10 - <Breadcrumb-item href="/">Home4</Breadcrumb-item>  
11 - <Breadcrumb-item href="/checkbox" replace>Components</Breadcrumb-item> 10 + <Breadcrumb-item to="/">Home4</Breadcrumb-item>
  11 + <Breadcrumb-item :to="{name: 'user', params: { userId: 123 }}">Components</Breadcrumb-item>
12 <Breadcrumb-item>Breadcrumb</Breadcrumb-item> 12 <Breadcrumb-item>Breadcrumb</Breadcrumb-item>
13 </Breadcrumb> 13 </Breadcrumb>
14 <Breadcrumb separator=""> 14 <Breadcrumb separator="">
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 <b style="color: #ff5500;">-></b> 18 <b style="color: #ff5500;">-></b>
19 </template> 19 </template>
20 </Breadcrumb-item> 20 </Breadcrumb-item>
21 - <Breadcrumb-item href="/components/breadcrumb"> 21 + <Breadcrumb-item href="/components/page">
22 <template>Breadcrumb</template> 22 <template>Breadcrumb</template>
23 <template slot="separator"> 23 <template slot="separator">
24 <b style="color: #ff5500;">-></b> 24 <b style="color: #ff5500;">-></b>
src/components/breadcrumb/breadcrumb-item.vue
1 <template> 1 <template>
2 <span> 2 <span>
3 - <a v-if="href" :class="linkClasses" @click="handleClick"> 3 + <a v-if="to || href" :class="linkClasses" @click="handleClick">
4 <slot></slot> 4 <slot></slot>
5 </a> 5 </a>
6 <span v-else :class="linkClasses"> 6 <span v-else :class="linkClasses">
@@ -13,13 +13,17 @@ @@ -13,13 +13,17 @@
13 </span> 13 </span>
14 </template> 14 </template>
15 <script> 15 <script>
  16 + // todo 3.0 时废弃 href
16 const prefixCls = 'ivu-breadcrumb-item'; 17 const prefixCls = 'ivu-breadcrumb-item';
17 18
18 export default { 19 export default {
19 name: 'BreadcrumbItem', 20 name: 'BreadcrumbItem',
20 props: { 21 props: {
21 href: { 22 href: {
22 - type: String 23 + type: [Object, String]
  24 + },
  25 + to: {
  26 + type: [Object, String]
23 }, 27 },
24 replace: { 28 replace: {
25 type: Boolean, 29 type: Boolean,
@@ -47,9 +51,9 @@ @@ -47,9 +51,9 @@
47 handleClick () { 51 handleClick () {
48 const isRoute = this.$router; 52 const isRoute = this.$router;
49 if (isRoute) { 53 if (isRoute) {
50 - this.replace ? this.$router.replace(this.href) : this.$router.push(this.href); 54 + this.replace ? this.$router.replace(this.to || this.href) : this.$router.push(this.to || this.href);
51 } else { 55 } else {
52 - window.location.href = this.href; 56 + window.location.href = this.to || this.href;
53 } 57 }
54 } 58 }
55 } 59 }