Trying to instantiate mdl into a vuejs project (vue v2.1). Running into a very similar issue to this, except when I call mounted () { componentHandler.upgradeDom()}
in my App.vue
, it's returning:
TypeError: _materialMin2.default.upgradeDom is not a function
Furthermore, if I type componentHander.upgradeDom()
in the browser console it'll do what's expected without error. If I console.log(componentHandler.upgradeDom())
in the mounted hook then it returns an emtpy object. Have tried adding a this.$nextTick
handler on mounted as well to no avail.
Am importing the material.js file like so:
import componentHandler from 'material-design-lite/material.min.js'
.
Tried to add it as a global as well just by dumping it in a script tag in index.html, and loading it by cdn, nothing seems to work properly.
For easy reading, this is what the whole thing looks like minus irrelevant stuff:
import componentHandler from 'material-design-lite/material.min.js'
export default {
name: 'app',
components: {
...
},
mounted () {
this.$nextTick(() => {
componentHandler.upgradeDom()
})
}
}
Also when I do it with ready () {..}
(old school vue) instead of mounted () {...}
it doesn't return the error, but also doesn't update each element correctly.