cretueusebiu/laravel-nuxt

Global Component not working.

huonsokly opened this issue · 3 comments

I've tried to declare global component but it not working however I did like this in single nuxt project it worked fine.

//plugins/ml.js
import Vue from 'vue'
import Title from '~/components/ml/title';
const components = { Title };
Object.entries(components).forEach(([name, component]) => {
Vue.component(name, component)
});

//nuxt.config.js
plugins: [
'~plugins/ml',
]

//in view file
<ml-title></ml-title>

but not working, please help!

Just use Vue.component(Title.name, Title)

Thank you for your answer!
but will it work with multiple components?

//plugins/ml.js
import Vue from 'vue'
import Title from '/components/ml/title';
import Title2 from '
/components/ml/title2';
const components = { Title, Title2 };
Object.entries(components).forEach(([name, component]) => {
Vue.component(name, component)
});

Thank you

I added this

components: {
dirs: [
'/components/',
{
path: '
/components/ml/',
prefix: 'ml'
}
]
},

in nuxt.config.js
and it worked. thank you!