Search code examples
vue.jsvue-componentvuejs3vue3-sfc-loader

how to import and use other components in a component loaded from vue3-sfc-loader?


I am using vue3-sfc-loader. I can get it working, but I am unable to use other components (also loaded from the same plugin) inside of a component. I have gone through documentation and searched whole day, but I am not able to figure out what am I missing.


Solution

  • I found the answer. Answering for anyone needing it.

    You can use import statement with relative path to your another component inside script tag of your SFC.

    Also, you need to include the component in list of components you want to use.

    import currency from './currency.vue';
    export default ({
        props: {
            ...
        },
        components: {
            'currency': currency
        },
        setup() {
            
        },
        ...
    

    Although someone in discussions on githhub mentions that you can use import statements.. it doesn't work.