Commit 5465ae45f7669a62b4d721ffc964e1215e13cec8
1 parent
72979a78
close #5378
Showing
2 changed files
with
14 additions
and
5 deletions
Show diff stats
examples/routers/button.vue
@@ -220,7 +220,9 @@ | @@ -220,7 +220,9 @@ | ||
220 | <Button type="default">Small</Button> | 220 | <Button type="default">Small</Button> |
221 | </Button-group> | 221 | </Button-group> |
222 | 222 | ||
223 | - <br><br><br><br><br> | 223 | + <br><br> |
224 | + <Button to="/icon">Open New Window</Button> | ||
225 | + <br><br><br> | ||
224 | </div> | 226 | </div> |
225 | </template> | 227 | </template> |
226 | <script> | 228 | <script> |
src/mixins/link.js
@@ -43,11 +43,18 @@ export default { | @@ -43,11 +43,18 @@ export default { | ||
43 | }, | 43 | }, |
44 | methods: { | 44 | methods: { |
45 | handleClick (new_window = false) { | 45 | handleClick (new_window = false) { |
46 | - if (new_window){ | ||
47 | - window.open(this.to); | 46 | + const router = this.$router; |
47 | + | ||
48 | + if (new_window) { | ||
49 | + let to = this.to; | ||
50 | + if (router) { | ||
51 | + const current = this.$route; | ||
52 | + const route = router.resolve(this.to, current, this.append); | ||
53 | + to = route ? route.href : this.to; | ||
54 | + } | ||
55 | + window.open(to); | ||
48 | } else { | 56 | } else { |
49 | - const isRoute = this.$router; | ||
50 | - if (isRoute) { | 57 | + if (router) { |
51 | this.replace ? this.$router.replace(this.to) : this.$router.push(this.to); | 58 | this.replace ? this.$router.replace(this.to) : this.$router.push(this.to); |
52 | } else { | 59 | } else { |
53 | window.location.href = this.to; | 60 | window.location.href = this.to; |