12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <template>
- <div class="crumbs">
- <ul>
- <li v-if="list[0]">
- <span class="name" :title="list[0].name" @click="onClickPath(0)">{{list[0].name}}</span>
- </li>
- <li v-if="list.length > 3">...</li>
- <li v-if="list.length > 2">
- <span class="name" :title="list[list.length - 2].name" @click="onClickPath(list.length - 2)">{{list[list.length - 2].name}}</span>
- </li>
- <li v-if="list.length > 1">
- <span class="name" :title="list[list.length - 1].name" @click="onClickPath(list.length - 1)">{{list[list.length - 1].name}}</span>
- </li>
- </ul>
- </div>
- </template>
- <script>
- export default {
- props:['list'],
- methods: {
- onClickPath(idx) {
- if (idx !== this.list.length - 1) {
- this.$emit('click-path', idx)
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .crumbs{
- >ul{
- display: flex;
- align-items: center;
- >li{
- font-size: 18px;
- color: #969799;
- line-height: 28px;
- .name{
- max-width: 285px;
- overflow: hidden;
- white-space: pre;
- text-overflow: ellipsis;
- cursor: pointer;
- }
- &::after {
- content: '>';
- margin-left: 7px;
- margin-right: 7px;
- }
- &:last-of-type{
- font-size: 18px;
- font-weight: bold;
- color: #333333;
- line-height: 28px;
- .name {
- cursor: default;
- }
- &::after {
- content: '';
- }
- }
- }
- }
- }
- </style>
|