Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Component Handler not defined #20

Closed
eurobob opened this issue Mar 18, 2016 · 14 comments
Closed

Component Handler not defined #20

eurobob opened this issue Mar 18, 2016 · 14 comments

Comments

@eurobob
Copy link

eurobob commented Mar 18, 2016

I get this console error when I include a component. I'm including the MDL javascript too, maybe i'm not including it in the right place? It's a little unclear in the documentation.

Uncaught ReferenceError: componentHandler is not defined

@eurobob
Copy link
Author

eurobob commented Mar 18, 2016

My bad! I had the defer attribute on the MDL js file, but not on my own js file.

I did however find that you need to include the MDL js before your own Vue instantiation, so perhaps this could be made clear in the docs?

@eurobob eurobob closed this as completed Mar 18, 2016
@posva
Copy link
Owner

posva commented Mar 18, 2016

Definitely! As there is already #13, I'll fix this as well on it

@pdcmoreira
Copy link

I'm having the same error on a fresh installation with vue-cli.

main.js:

var VueMdl = require('vue-mdl');
var Vue = require('vue');
var App = require('./App');

Vue.use(VueMdl.default);

new Vue({
    el: 'body',

    components: {
        App: App
    }
});

App.vue:

<template>
    <div id="app">
        <img class="logo" src="./assets/logo.png">

        <mdl-button>Button</mdl-button>
        <mdl-button v-mdl-ripple-effect>Ripple Effect</mdl-button>
        <mdl-button disabled>Disabled</mdl-button>
        <mdl-button icon>
            <i class="material-icons">star</i>
        </mdl-button>
    </div>
</template>

<script>
    export default {
    }
</script>

<style>
</style>

The buttons appear unstyled, with the error on the console:
Uncaught ReferenceError: componentHandler is not defined

@posva
Copy link
Owner

posva commented Apr 10, 2016

@pdcmoreira You need to include MDL too: http://www.getmdl.io/started/index.html

@pdcmoreira
Copy link

Ok, so I've included MDL through the "hosted" method and now the buttons are correctly styled, but the Uncaught ReferenceError: componentHandler is not defined error is still in the console. Do you have any idea?

@posva
Copy link
Owner

posva commented Apr 10, 2016

you must be missing the mdl js. check mdl website again 😄

@pdcmoreira
Copy link

Are you refering to the material.js? I've added these 3 lines to my <head> tag, as it says in the mdl website:

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script>

@posva
Copy link
Owner

posva commented Apr 10, 2016

you should remove the defer

@pdcmoreira
Copy link

Perfect! Thanks! It's not obvious in the vue-mdl documentation that we should include MDL first, though.

@posva
Copy link
Owner

posva commented Apr 10, 2016

Yeah, where do you think it should be? Where do you expected itto be?

@pdcmoreira
Copy link

In the Installation section, there should be some note saying it doesn't include MDL, therefore we should include it first. I think. Or maybe I'm just being noob.

@posva
Copy link
Owner

posva commented Apr 10, 2016

There's already a note but I've seen a lot of people struggling with this when they start

@euan-smith
Copy link

No problem realising what I had to setup from MDL, but like the other posters had not spotted the 'defer' attribute after copy-pasting the script tag from the MDL documentation. It'd be helpful, I think, to add a comment about that.

@posva
Copy link
Owner

posva commented May 18, 2016

@zalkawe314 Could you make the PR for it, please 😄 ?
Edit: Oh, it's on their documentation? I didn't notice that
Edit2: Done!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants