vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

Vue webpack module not exporting #379

Open IntellectProductions opened 9 years ago

IntellectProductions commented 9 years ago

I'm following this guide: https://github.com/vuejs/vue-webpack-example

I have webpack working, but it seems when I hit a double nested module.exports thing, it doesn't issue it. It's being included, but doesn't actually function. This is my setup:

My Vue instance:

var NavigationInstance = new Vue({
    el: '#main-nav',

    components: {
        'navigation': require('../../components/navigation/Navigation')
    }
});

My Navigation component (which loads EVERYTHING including ready methods and such):

module.exports = {
    template: require('./templates/navigation.html'),

    replace: true,

    data: function() {
        return {
            styles: {}
        }
    },

    ready: function() {
        console.log('nav comp loaded');
    },

    components: {
        'dropdown': require('./Dropdown'),
        'navlink': require('./NavLink')
    }
};

Now when it gets to the dropdown and navlink, the files are included, but no methods or anything will work:

module.exports = {
    template: require('./templates/navlink.html'),

    replace: true,

    data: function() {
        return {
        }
    },

    props: ['text', 'url'],

    mixins: require('./../mixins/Viewport'),

    ready: function() {
        console.log('nav link loaded');
    },

    methods: {
        handleClick: function(e) {
            e.preventDefault();

            if( this.isMobile() && this.$children.length )
            {
                // Has dropdown on mobile so don't redirect
                this.$children[0].dropDown();
            }
            else
            {
                // Not mobile so let user go
                window.location = this.url;
            }
        }
    }
};
console.log('nav link file loaded');

The "nav link file loaded" writes to the console, but the "nav link loaded" won't which is in the ready method.. the drop down and nav link components aren't actually starting up as nested components. I feel like I have everything setup like the example, but it won't work. The "nav comp loaded" in the navigation component issues too so that one works great.

Thank you for any insight!