FranckFreiburger / http-vue-loader

load .vue files from your html/js
MIT License
1.48k stars 273 forks source link

Use Custom Components in Custom Components #124

Closed OfficialCRUGG closed 2 years ago

OfficialCRUGG commented 3 years ago

I think the title is pretty self-explanatory: How would I use CustomButton inside CustomNavbar for example?

I import CustomNavbar in the index.html File using:

new Vue({
    el: "#root",
    components: {
        "custom-navbar": httpVueLoader("js/components/CustomNavbar.vue"),
    }
});

which by itself works. But now I want to use CustomButton inside the CustomNavbar File. How would I do this?

tavvvv commented 3 years ago

Import it inside the CustomNavbar.vue like this:

<template>
    <custombutton></custombutton>
</template>

<script>

    module.exports = {

        components:{
            'custombutton': httpVueLoader('js/CustomButton.vue'),
        },

        data: function(){

            return {

            }

        },

    }

</script>
<style>

</style>

Alternatively you can register the component globally using the httpVueLoader.register() method