Ben tek bir dosya bileşenlerin içinde (Vue.component ile) küresel kayıtlı bileşeni kullanmak çalışıyorum ama hepTek dosya bileşenlerinde VueJS 2 global bileşenleri nasıl kullanılır?
Örneğinvue.common.js:2611[Vue warn]: Unknown custom element: <my-component> - did you register the component correctly?
alıyorum:
main.js:
...
Vue.component('my-component', {
name: 'my-component',
template: '<div>A custom component!</div>'
})
...
home.vue:
<template>
<div>
<my-component></my-component>
</div>
</template>
<script>
module.exports = {
name: 'home'
}
</script>
Ben yerel olarak kayıt varsa
, Tamam çalışır:
<template>
<div>
<my-component></my-component>
</div>
</template>
<script>
module.exports = {
name: 'home',
components: {
'my-component': require('./my-component.vue')
}
}
</script>
Bileşeni bir yere koymanız gerekiyor, aksi halde indirilmeyecek. – Elfayer
@Elfayer Her şey, Vueify tarafından oluşturulan bir paket içinde ve main.js dosyasında ana bileşen gereklidir. –