Skip to content

Instantly share code, notes, and snippets.

@eirikb
Last active May 24, 2017 19:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eirikb/c1456d978b5230f8f4caab6e8f5b0e49 to your computer and use it in GitHub Desktop.
Save eirikb/c1456d978b5230f8f4caab6e8f5b0e49 to your computer and use it in GitHub Desktop.
Add MDL to all elements with "mdl-js"-class in Vue
import 'material-design-lite'
Vue.mixin({
mounted() {
if (!this.$el || !this.$el.querySelectorAll) return;
componentHandler.upgradeElement(this.$el);
for (const el of this.$el.querySelectorAll('[class*=mdl-js-]')) {
if (!el.dataset.upgraded) {
componentHandler.upgradeElement(el);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment