Skip to content

Commit 271f059

Browse files
committed
fix(MdButton): read all router link properties and bind to button props
1 parent 298879f commit 271f059

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/components/MdButton/MdButton.vue

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
type: String,
1616
default: 'button'
1717
},
18-
disabled: Boolean,
19-
mdRipple: {
20-
type: Boolean,
21-
default: true
22-
},
23-
to: [String, Object]
18+
disabled: Boolean
2419
},
2520
render (createElement) {
2621
const buttonContent = createElement('md-button-content', {
@@ -53,11 +48,8 @@
5348
if (this.href) {
5449
tag = 'a'
5550
} else if (this.$router && this.to) {
51+
buttonAttrs.props = this.$props
5652
tag = 'router-link'
57-
buttonAttrs.attrs = {
58-
...this.$options.propsData,
59-
to: this.to
60-
}
6153
}
6254
6355
return createElement(tag, buttonAttrs, [buttonContent])

src/components/MdButton/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import MdButton from './MdButton'
22

33
export default Vue => {
4+
const routerLinkProps = Vue.options.components['router-link'].options.props
5+
6+
delete routerLinkProps.to.required
7+
8+
MdButton.props = {
9+
...MdButton.props,
10+
...routerLinkProps
11+
}
12+
413
Vue.component(MdButton.name, MdButton)
514
}

0 commit comments

Comments
 (0)