vue-material/src/components/mdButton/mdButton.vue

42 lines
905 B
Vue
Raw Normal View History

2016-07-13 05:00:31 +00:00
<style lang="scss" src="./mdButton.scss"></style>
2016-06-21 06:54:17 +00:00
2016-07-15 00:06:29 +00:00
<script>
export default {
2016-09-08 05:15:03 +00:00
props: {
href: String,
type: String,
disabled: Boolean
},
render(createElement) {
let isDisabled = Boolean(this.disabled);
let hasLink = Boolean(this.href);
let tag = 'button';
let options = {
staticClass: 'md-button',
attrs: {
type: this.type || 'button',
disabled: isDisabled
},
on: {
2016-09-09 16:46:29 +00:00
click: () => {
this.$emit('click');
}
}
};
2016-10-25 07:09:44 +00:00
let ripple = createElement('md-ink-ripple', {
attrs: {
mdDisabled: isDisabled
}
});
if (hasLink) {
tag = 'a';
options.attrs.href = this.href;
delete options.attrs.type;
}
2016-10-25 07:09:44 +00:00
return createElement(tag, options, [...this.$slots.default, ripple]);
2016-07-15 00:06:29 +00:00
}
};
</script>