Commit aa90e9f165ae94f1c12ed012eff6068fba35cc43

Authored by 严涛
1 parent a40c40a2

标题 面包屑组件封装

  1 +export { default as BreadcrumbIot } from './index.vue';
... ...
  1 +<template>
  2 + <div class="layout">
  3 + <a-breadcrumb>
  4 + <a-breadcrumb-item v-for="(item, index) in breadcrumbList" :key="index">
  5 + <a v-if="index < breadcrumbList.length - 1" @click="handleBreadcrumbClick(item.query)">{{
  6 + item.title
  7 + }}</a>
  8 + <span v-else>{{ item.title }}</span>
  9 + </a-breadcrumb-item>
  10 + </a-breadcrumb>
  11 + </div>
  12 +</template>
  13 +
  14 +<script setup lang="ts">
  15 + import { useRouter, useRoute } from 'vue-router';
  16 + import { useI18n } from '/@/hooks/web/useI18n';
  17 + import { defineProps } from 'vue';
  18 +
  19 + const { t } = useI18n();
  20 + const router = useRouter();
  21 + const route = useRoute();
  22 +
  23 + // 定义接收父组件传递的面包屑数据的 props
  24 + const props = defineProps({
  25 + breadcrumbList: {
  26 + type: Array as () => Array<{ title: string; query?: string }>,
  27 + default: () => [],
  28 + },
  29 + });
  30 +
  31 + // 处理面包屑点击事件
  32 + const handleBreadcrumbClick = (query?: string) => {
  33 + if (query) {
  34 + router.push({
  35 + path: route.path,
  36 + query: { type: query },
  37 + });
  38 + } else {
  39 + router.go(-1);
  40 + }
  41 + };
  42 +</script>
  43 +
  44 +<style scoped lang="less">
  45 + .layout {
  46 + padding: 6px 10px 6px 10px;
  47 + margin-bottom: 16px;
  48 + background-color: #fff;
  49 + font-size: 14px;
  50 + .ant-breadcrumb {
  51 + height: 46px;
  52 + line-height: 46px;
  53 + }
  54 + }
  55 +</style>
... ...
  1 +export { default as ModuleTitle } from './index.vue';
... ...
  1 +<template>
  2 + <div class="title">{{ title }}</div>
  3 +</template>
  4 +
  5 +<script setup lang="ts">
  6 + import { defineProps } from 'vue';
  7 + // 定义接收父组件传递的标题属性
  8 + const props = defineProps({
  9 + title: {
  10 + type: String,
  11 + default: '默认标题',
  12 + },
  13 + });
  14 +</script>
  15 +
  16 +<style scoped lang="less">
  17 + .title {
  18 + height: 50px;
  19 + line-height: 50px;
  20 + border-bottom: 1px solid #d9d9d9;
  21 + font-size: 16px;
  22 + padding-left: 15px;
  23 + margin-bottom: 15px;
  24 + }
  25 +</style>
... ...