我的问题与[Vue/Vuetify - Unknown custom element: <v-app> - did you register the component correctly?非常相似,但有一个区别。!
我制作了一个使用vuetify组件(v-sheet,v-card等)的自定义vue组件,然后按照guide,我通过npm使该组件可用。
在我的nuxt应用程序中,我从库中导入组件并将其注册在页面中。
然后,我收到有关v组件未递归注册的警告。我的自定义组件已命名。我的nuxt应用程序使用vuetify。
如果我添加
import Vuetify from 'vuetify'
import Vue from 'vue'
Vue.use(Vuetify)
在自定义组件的脚本标签顶部(如链接的SO文章中所建议),这不能解决问题。
如果我将它添加到default.vue(用于nuxt布局)中,则会这样做。
在我的入口点index.js
中,
import Vue from 'vue';
// I have tried adding vuetify here
import MyComponent from './components/MyComponent.vue';
const components = {
MyComponent
}
function install(Vue) {
if (install.installed) return;
install.installed = true;
// I have tried adding vuetify here
Object.keys(components).forEach(name => {
// I have tried adding vuetify here
Vue.component(name, components[name])
});
}
const plugin = {
install,
}
let GlobalVue = null;
if (typeof window !== 'undefined') {
GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue;
}
if (GlobalVue) {
// I have tried adding vuetify here
GlobalVue.use(plugin);
// I have tried adding vuetify here
}
export default components
export {
MyComponent
}
如何解决此问题,这样就不必在nuxt应用程序中重新加载vuetify?