breadcrumb-item.vue 998 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <li class="m-breadcrumb-item">
  3. <a class="m-breadcrumb-item__link" :href="to" @click="handleClick" v-if="to">
  4. <slot></slot>
  5. </a>
  6. <span class="m-breadcrumb-item__span" v-else>
  7. <slot/>
  8. </span>
  9. <span>
  10. <i class="m-breadcrumb-item__separator iconfont" :class="separatorClass" v-if="separatorClass"></i>
  11. <span class="m-breadcrumb-item__separator" v-else> {{ separator }} </span>
  12. </span>
  13. </li>
  14. </template>
  15. <script>
  16. export default {
  17. name: "mBreadcrumbItem"
  18. };
  19. </script>
  20. <script setup>
  21. import { inject } from 'vue-demi';
  22. import { useRouter } from 'vue-router';
  23. const props = defineProps({
  24. to: {
  25. type: [String, Object],
  26. }
  27. })
  28. const router = useRouter()
  29. const breadcrumbKey = inject('breadcrumbKey')
  30. const { separator,separatorClass } = breadcrumbKey
  31. const handleClick = (e) => {
  32. event.preventDefault();
  33. router.push(props.to)
  34. }
  35. </script>
  36. <style lang="scss" scoped>
  37. @import '../../../styles/components/breadcrumb.scss';
  38. </style>