Merge pull request #5341 from rijulg/2.0

Updated Button's link processor logic
This commit is contained in:
Aresn 2019-04-08 16:09:45 +08:00 committed by GitHub
commit 574ec50425
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,12 +15,30 @@ export default {
return oneOf(value, ['_blank', '_self', '_parent', '_top']); return oneOf(value, ['_blank', '_self', '_parent', '_top']);
}, },
default: '_self' default: '_self'
} },
append: {
type: Boolean,
required: false,
default: false,
},
}, },
computed: { computed: {
linkUrl () { linkUrl () {
const type = typeof this.to; const type = typeof this.to;
return type === 'string' ? this.to : null; if (type !== 'string') {
return null;
}
if (this.to.includes('//')) {
/* Absolute URL, we do not need to route this */
return this.to;
}
const router = this.$router;
if (router) {
const current = this.$route;
const route = router.resolve(this.to, current, this.append);
return route ? route.href : this.to;
}
return this.to;
} }
}, },
methods: { methods: {