Commit 05265beef7670ae28a5fb98338d43f73f6ac0f28

Authored by 梁灏
1 parent 6d2b7bcb

fixed #2214

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