fix: to remove vue-router dep (#670)

This commit is contained in:
zazzaz 2020-11-24 14:59:06 +08:00 committed by GitHub
parent a2a515024a
commit 857715564b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -4,8 +4,7 @@
"main": "dist/index.js",
"license": "MIT",
"peerDependencies": {
"vue": "^3.0.0",
"vue-router": "^4.0.0-beta.4"
"vue": "^3.0.0"
},
"devDependencies": {
"@vue/test-utils": "^2.0.0-beta.3"

View File

@ -14,7 +14,6 @@
<script lang="ts">
import { defineComponent, inject, ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
interface IBreadcrumbInject {
separator: string
@ -38,16 +37,15 @@ export default defineComponent({
default: false,
},
},
setup(props: IBreadcrumbItemProps) {
setup(props: IBreadcrumbItemProps, ctx) {
const link = ref(null)
const parent: IBreadcrumbInject = inject('breadcrumb')
onMounted(() => {
link.value.setAttribute('role', 'link')
link.value.addEventListener('click', () => {
if (!props.to) return
const router = useRouter()
if (!router) return
const router = (ctx as any).$router
if (!props.to || !router) return
props.replace ? router.replace(props.to) : router.push(props.to)
})
})