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:
qige2016 2021-07-05 20:54:06 -05:00 committed by GitHub
parent 6b4c04fd0a
commit 7bc6baf495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 20 deletions

View File

@ -0,0 +1,4 @@
export interface IBreadcrumbProps {
separator: string
separatorClass: string
}

View File

@ -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')

View File

@ -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