Skip to content

Commit cf987a3

Browse files
committed
feat: [Request] QBtn router handling ("to" and "replace" props) quasarframework#2058
1 parent 4c4f4c0 commit cf987a3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

dev/components/components/button.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
</q-toolbar>
4747

4848
<br><br>
49+
<p>
50+
<q-btn label="Go to index page" to="/" />
51+
</p>
4952
<p>
5053
<form @submit.prevent="submit" @reset.prevent="reset" class="shadow-2 row q-pa-md items-center">
5154
<q-input v-model="test" class="col" />

src/components/btn/QBtn.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export default {
99
percentage: Number,
1010
darkPercentage: Boolean,
1111
waitForRipple: Boolean,
12-
repeatTimeout: [Number, Function]
12+
repeatTimeout: [Number, Function],
13+
to: [Object, String],
14+
replace: Boolean
1315
},
1416
computed: {
1517
hasPercentage () {
@@ -51,6 +53,10 @@ export default {
5153
}
5254

5355
this.$emit('click', e)
56+
57+
if (this.to !== void 0) {
58+
this.$router[this.replace ? 'replace' : 'push'](this.to)
59+
}
5460
}
5561

5662
if (this.waitForRipple && this.hasRipple) {

0 commit comments

Comments
 (0)