Commit 7ff2f71a2f9db26890bdfe5ecdfb06ac907c4d06
1 parent
9d553a2b
fix
修复on-select事件不触发
Showing
2 changed files
with
11 additions
and
9 deletions
Show diff stats
src/components/anchor/anchor-link.vue
| ... | ... | @@ -5,11 +5,9 @@ |
| 5 | 5 | </div> |
| 6 | 6 | </template> |
| 7 | 7 | <script> |
| 8 | -import mixinsLink from '../../mixins/link'; | |
| 9 | 8 | export default { |
| 10 | 9 | name: 'AnchorLink', |
| 11 | 10 | inject: ['anchorCom'], |
| 12 | - mixins: [ mixinsLink ], | |
| 13 | 11 | props: { |
| 14 | 12 | href: String, |
| 15 | 13 | title: String |
| ... | ... | @@ -33,10 +31,15 @@ export default { |
| 33 | 31 | } |
| 34 | 32 | }, |
| 35 | 33 | methods: { |
| 36 | - goAnchor (event) { | |
| 34 | + goAnchor () { | |
| 37 | 35 | this.currentLink = this.href; |
| 38 | - this.$emit('on-select', this.href); | |
| 39 | - this.handleCheckClick(event); | |
| 36 | + this.anchorCom.$emit('on-select', this.href); | |
| 37 | + const isRoute = this.$router; | |
| 38 | + if (isRoute) { | |
| 39 | + this.$router.push(this.href); | |
| 40 | + } else { | |
| 41 | + window.location.href = this.href; | |
| 42 | + } | |
| 40 | 43 | } |
| 41 | 44 | }, |
| 42 | 45 | mounted () { | ... | ... |
src/mixins/link.js
| ... | ... | @@ -26,15 +26,14 @@ export default { |
| 26 | 26 | methods: { |
| 27 | 27 | handleClick () { |
| 28 | 28 | const isRoute = this.$router; |
| 29 | - const href = this.to || this.href; | |
| 30 | 29 | if (isRoute) { |
| 31 | - this.replace ? this.$router.replace(href) : this.$router.push(href); | |
| 30 | + this.replace ? this.$router.replace(this.to) : this.$router.push(this.to); | |
| 32 | 31 | } else { |
| 33 | - window.location.href = href; | |
| 32 | + window.location.href = this.to; | |
| 34 | 33 | } |
| 35 | 34 | }, |
| 36 | 35 | handleCheckClick (event) { |
| 37 | - if (this.to || this.href) { | |
| 36 | + if (this.to) { | |
| 38 | 37 | if (this.target === '_blank') { |
| 39 | 38 | return false; |
| 40 | 39 | } else { | ... | ... |