7fa943eb
梁灏
init
|
1
2
|
<template>
<span>
|
05265bee
梁灏
fixed #2214
|
3
|
<a v-if="to || href" :class="linkClasses" @click="handleClick">
|
7fa943eb
梁灏
init
|
4
5
6
7
8
|
<slot></slot>
</a>
<span v-else :class="linkClasses">
<slot></slot>
</span>
|
dcbfc232
梁灏
add name of Bread...
|
9
|
<span :class="separatorClasses" v-html="separator" v-if="!showSeparator"></span>
|
c06e99d0
huixisheng
Support Breadcrumb
|
10
11
|
<span :class="separatorClasses" v-else>
<slot name="separator"></slot>
|
7fa943eb
梁灏
init
|
12
13
14
15
|
</span>
</span>
</template>
<script>
|
05265bee
梁灏
fixed #2214
|
16
|
// todo 3.0 时废弃 href
|
7fa943eb
梁灏
init
|
17
18
19
|
const prefixCls = 'ivu-breadcrumb-item';
export default {
|
dcbfc232
梁灏
add name of Bread...
|
20
|
name: 'BreadcrumbItem',
|
7fa943eb
梁灏
init
|
21
22
|
props: {
href: {
|
05265bee
梁灏
fixed #2214
|
23
24
25
26
|
type: [Object, String]
},
to: {
type: [Object, String]
|
345c6863
梁灏
update Breadcrumb
|
27
28
29
30
|
},
replace: {
type: Boolean,
default: false
|
7fa943eb
梁灏
init
|
31
32
|
}
},
|
c06e99d0
huixisheng
Support Breadcrumb
|
33
34
35
36
|
data () {
return {
separator: '',
showSeparator: false
|
44412093
huixisheng
[fixed] eslint error
|
37
|
};
|
c06e99d0
huixisheng
Support Breadcrumb
|
38
|
},
|
7fa943eb
梁灏
init
|
39
40
41
42
43
44
45
|
computed: {
linkClasses () {
return `${prefixCls}-link`;
},
separatorClasses () {
return `${prefixCls}-separator`;
}
|
345c6863
梁灏
update Breadcrumb
|
46
47
48
49
50
51
52
53
|
},
mounted () {
this.showSeparator = this.$slots.separator !== undefined;
},
methods: {
handleClick () {
const isRoute = this.$router;
if (isRoute) {
|
05265bee
梁灏
fixed #2214
|
54
|
this.replace ? this.$router.replace(this.to || this.href) : this.$router.push(this.to || this.href);
|
345c6863
梁灏
update Breadcrumb
|
55
|
} else {
|
05265bee
梁灏
fixed #2214
|
56
|
window.location.href = this.to || this.href;
|
345c6863
梁灏
update Breadcrumb
|
57
58
|
}
}
|
7fa943eb
梁灏
init
|
59
|
}
|
b0893113
jingsam
add eslint
|
60
61
|
};
</script>
|