修复on-select事件不触发
This commit is contained in:
zhigang.li 2018-06-29 18:25:41 +08:00
parent 9d553a2b81
commit 7ff2f71a2f
2 changed files with 11 additions and 9 deletions

View file

@ -5,11 +5,9 @@
</div> </div>
</template> </template>
<script> <script>
import mixinsLink from '../../mixins/link';
export default { export default {
name: 'AnchorLink', name: 'AnchorLink',
inject: ['anchorCom'], inject: ['anchorCom'],
mixins: [ mixinsLink ],
props: { props: {
href: String, href: String,
title: String title: String
@ -33,10 +31,15 @@ export default {
} }
}, },
methods: { methods: {
goAnchor (event) { goAnchor () {
this.currentLink = this.href; this.currentLink = this.href;
this.$emit('on-select', this.href); this.anchorCom.$emit('on-select', this.href);
this.handleCheckClick(event); const isRoute = this.$router;
if (isRoute) {
this.$router.push(this.href);
} else {
window.location.href = this.href;
}
} }
}, },
mounted () { mounted () {

View file

@ -26,15 +26,14 @@ export default {
methods: { methods: {
handleClick () { handleClick () {
const isRoute = this.$router; const isRoute = this.$router;
const href = this.to || this.href;
if (isRoute) { 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 { } else {
window.location.href = href; window.location.href = this.to;
} }
}, },
handleCheckClick (event) { handleCheckClick (event) {
if (this.to || this.href) { if (this.to) {
if (this.target === '_blank') { if (this.target === '_blank') {
return false; return false;
} else { } else {