mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-03 11:47:48 +08:00
refactor(breadcrumb): refactor the type definition of breadcrumb (#2443)
* refactor(breadcrumb): refactor the type definition of breadcrumb * chore(breadcrumb): fix types import
This commit is contained in:
parent
6b4c04fd0a
commit
7bc6baf495
4
packages/breadcrumb/src/breadcrumb.ts
Normal file
4
packages/breadcrumb/src/breadcrumb.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export interface IBreadcrumbProps {
|
||||
separator: string
|
||||
separatorClass: string
|
||||
}
|
@ -11,11 +11,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, provide, ref, onMounted } from 'vue'
|
||||
|
||||
interface IBreadcrumbProps {
|
||||
separator: string
|
||||
separatorClass: string
|
||||
}
|
||||
import type { IBreadcrumbProps } from './breadcrumb'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ElBreadcrumb',
|
||||
@ -29,10 +25,10 @@ export default defineComponent({
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
setup(props: IBreadcrumbProps) {
|
||||
setup(props) {
|
||||
const breadcrumb = ref(null)
|
||||
|
||||
provide('breadcrumb', props)
|
||||
provide<IBreadcrumbProps>('breadcrumb', props)
|
||||
|
||||
onMounted(() => {
|
||||
const items = breadcrumb.value.querySelectorAll('.el-breadcrumb__item')
|
||||
|
@ -26,22 +26,14 @@ import {
|
||||
onMounted,
|
||||
getCurrentInstance,
|
||||
} from 'vue'
|
||||
|
||||
interface IBreadcrumbInject {
|
||||
separator: string
|
||||
separatorClass: string
|
||||
}
|
||||
|
||||
interface IBreadcrumbItemProps {
|
||||
to: string | Record<string, unknown>
|
||||
replace: boolean
|
||||
}
|
||||
import type { IBreadcrumbProps } from './breadcrumb'
|
||||
import type { PropType } from 'vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ElBreadcrumbItem',
|
||||
props: {
|
||||
to: {
|
||||
type: [String, Object],
|
||||
type: [String, Object] as PropType<string | Record<string, unknown>>,
|
||||
default: '',
|
||||
},
|
||||
replace: {
|
||||
@ -49,9 +41,9 @@ export default defineComponent({
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
setup(props: IBreadcrumbItemProps) {
|
||||
setup(props) {
|
||||
const link = ref(null)
|
||||
const parent: IBreadcrumbInject = inject('breadcrumb')
|
||||
const parent = inject<IBreadcrumbProps>('breadcrumb')
|
||||
const instance = getCurrentInstance()
|
||||
const router = instance.appContext.config.globalProperties.$router
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user