Created
May 3, 2018 13:16
-
-
Save ducan-ne/9cdc5298d5aadffaf4d788871e8861d9 to your computer and use it in GitHub Desktop.
<button is="ladda" :loading="isLoading">Submit</button>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ladda from 'ladda' | |
export default { | |
props: ['loading'], | |
render(h) { | |
return h('button', this.$slots.default) | |
}, | |
mounted() { | |
this.$el.className += ' ladda-button' | |
this.$el['data-spinner-size'] = 35 | |
this.$el['data-spinner-color'] = '#ffffff' | |
this.ladda = Ladda.create(this.$el) | |
this.renderLoader() | |
}, | |
methods: { | |
renderLoader() { | |
if (this.loading == true) { | |
!this.ladda.isLoading() && this.ladda.start() | |
return | |
} | |
this.ladda.stop() | |
} | |
}, | |
watch: { | |
loading(val) { | |
this.renderLoader() | |
} | |
}, | |
beforeDestroy() { | |
this.ladda.remove() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment