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';/components/ml/title2';
import Title2 from '
const components = { Title, Title2 };
Object.entries(components).forEach(([name, component]) => {
Vue.component(name, component)
});
Thank you
I added this
components: {
dirs: [
'/components/',/components/ml/',
{
path: '
prefix: 'ml'
}
]
},
in nuxt.config.js
and it worked. thank you!