Skip to content

Commit 1fe8824

Browse files
author
bootstrap-vue-bot
committed
Improve Button & Nav-Item link handling
1 parent d1c75ac commit 1fe8824

File tree

2 files changed

+48
-46
lines changed

2 files changed

+48
-46
lines changed

components/button.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<template>
22
<button :class="classObject"
3-
@click.stop.prevent="click"
3+
@click="onclick"
44
:href="href || to"
55
:is="componentType"
66
:to="to || href"
77
:exact="exact"
8+
:target="target"
89
>
910
<slot></slot>
1011
</button>
@@ -63,22 +64,24 @@
6364
},
6465
variant: {
6566
type: String,
66-
default: 'secondary'
67+
default: 'primary'
6768
},
6869
to: {
6970
type: [String, Object],
70-
default: ''
7171
},
7272
href: {
7373
type: String
7474
},
7575
exact: {
7676
type: Boolean,
7777
default: false
78+
},
79+
target: {
80+
type: String,
7881
}
7982
},
8083
methods: {
81-
click() {
84+
onclick() {
8285
this.$emit('click', this.to);
8386
if (this.$router && this.to) {
8487
this.$router.push(this.to);

components/nav-item.vue

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<template>
22
<li class="nav-item">
33
<component
4-
class="nav-item"
54
:class="classObject"
6-
@click.stop.prevent="onclick"
7-
:href="to"
5+
@click="onclick"
6+
:href="href || to"
87
:is="componentType"
98
active-class="active"
109
:to="to"
1110
:exact="exact"
11+
:target="target"
1212
>
1313
<slot></slot>
1414
</component>
@@ -17,47 +17,46 @@
1717

1818
<script>
1919
20-
export default {
21-
computed: {
22-
classObject() {
23-
return [
24-
'nav-link',
25-
this.active ? 'active' : '',
26-
this.disabled ? 'disabled' : ''
27-
];
28-
},
29-
componentType() {
30-
return this.to ? 'router-link' : 'a';
31-
}
32-
},
33-
props: {
34-
active: {
35-
type: Boolean,
36-
default: false
37-
},
38-
disabled: {
39-
type: Boolean,
40-
default: false
20+
export default {
21+
computed: {
22+
classObject() {
23+
return [
24+
'nav-link',
25+
this.active ? 'active' : '',
26+
this.disabled ? 'disabled' : ''
27+
];
28+
},
29+
componentType() {
30+
return this.to ? 'router-link' : 'a';
31+
}
4132
},
42-
to: {
43-
type: [String, Object],
44-
default: ''
33+
props: {
34+
active: {
35+
type: Boolean,
36+
default: false
37+
},
38+
disabled: {
39+
type: Boolean,
40+
default: false
41+
},
42+
to: {
43+
type: [String, Object],
44+
},
45+
href: {
46+
type: String,
47+
},
48+
exact: {
49+
type: Boolean,
50+
default: false
51+
},
52+
target: {
53+
type: String,
54+
}
4555
},
46-
exact: {
47-
type: Boolean,
48-
default: false
49-
}
50-
},
51-
methods: {
52-
onclick() {
53-
this.$emit('click', this.to);
54-
55-
if (this.to) {
56-
if (this.$router) {
57-
this.$router.push(this.to);
58-
}
56+
methods: {
57+
onclick() {
58+
this.$emit('click', this.to);
5959
}
6060
}
61-
}
62-
};
61+
};
6362
</script>

0 commit comments

Comments
 (0)