Created
August 1, 2017 17:38
-
-
Save AlbinoDrought/a02f1f4106731710ec79ccdc9caa7380 to your computer and use it in GitHub Desktop.
Vue.js mixin to reduce `mount` and `watch` boilerplate
This file contains 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
function mountWatch(propName, methodName) { | |
const mixin = { | |
mounted() { | |
this[methodName](); | |
}, | |
watch: { | |
[propName]() { | |
this[methodName](); | |
}, | |
}, | |
}; | |
return mixin; | |
} | |
export default mountWatch; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment