Commit 574ec504251869e80ef2d20dd63b77429ce0e7bf

Authored by Aresn
Committed by GitHub
2 parents 2739fc29 ad93e7a6

Merge pull request #5341 from rijulg/2.0

Updated Button's link processor logic
Showing 1 changed file with 20 additions and 2 deletions   Show diff stats
src/mixins/link.js
... ... @@ -15,12 +15,30 @@ export default {
15 15 return oneOf(value, ['_blank', '_self', '_parent', '_top']);
16 16 },
17 17 default: '_self'
18   - }
  18 + },
  19 + append: {
  20 + type: Boolean,
  21 + required: false,
  22 + default: false,
  23 + },
19 24 },
20 25 computed: {
21 26 linkUrl () {
22 27 const type = typeof this.to;
23   - return type === 'string' ? this.to : null;
  28 + if (type !== 'string') {
  29 + return null;
  30 + }
  31 + if (this.to.includes('//')) {
  32 + /* Absolute URL, we do not need to route this */
  33 + return this.to;
  34 + }
  35 + const router = this.$router;
  36 + if (router) {
  37 + const current = this.$route;
  38 + const route = router.resolve(this.to, current, this.append);
  39 + return route ? route.href : this.to;
  40 + }
  41 + return this.to;
24 42 }
25 43 },
26 44 methods: {
... ...