diff --git a/src/components/anchor/anchor-link.vue b/src/components/anchor/anchor-link.vue index 3c9eab2d..999609db 100644 --- a/src/components/anchor/anchor-link.vue +++ b/src/components/anchor/anchor-link.vue @@ -5,11 +5,9 @@ </div> </template> <script> -import mixinsLink from '../../mixins/link'; export default { name: 'AnchorLink', inject: ['anchorCom'], - mixins: [ mixinsLink ], props: { href: String, title: String @@ -33,10 +31,15 @@ export default { } }, methods: { - goAnchor (event) { + goAnchor () { this.currentLink = this.href; - this.$emit('on-select', this.href); - this.handleCheckClick(event); + this.anchorCom.$emit('on-select', this.href); + const isRoute = this.$router; + if (isRoute) { + this.$router.push(this.href); + } else { + window.location.href = this.href; + } } }, mounted () { diff --git a/src/mixins/link.js b/src/mixins/link.js index 0b016f79..c1ca1872 100644 --- a/src/mixins/link.js +++ b/src/mixins/link.js @@ -26,15 +26,14 @@ export default { methods: { handleClick () { const isRoute = this.$router; - const href = this.to || this.href; if (isRoute) { - this.replace ? this.$router.replace(href) : this.$router.push(href); + this.replace ? this.$router.replace(this.to) : this.$router.push(this.to); } else { - window.location.href = href; + window.location.href = this.to; } }, handleCheckClick (event) { - if (this.to || this.href) { + if (this.to) { if (this.target === '_blank') { return false; } else {