Javascript 为什么我的项目中的vuetify在.js文件和.vue文件中使用时会中断
当我从index.js文件中包括vuetifyJavascript 为什么我的项目中的vuetify在.js文件和.vue文件中使用时会中断,javascript,webpack,vue.js,vuetify.js,Javascript,Webpack,Vue.js,Vuetify.js,当我从index.js文件中包括vuetifyvuetify.use(vuetify)时,我会遇到这个错误 vue.esm.js?a026:591 [Vue warn]: Unknown custom element: <v-app> - did you register the component correctly? For recursive components, make sure to provide the "name" option. App.vue //其他自定
vuetify.use(vuetify)
时,我会遇到这个错误
vue.esm.js?a026:591 [Vue warn]: Unknown custom element: <v-app> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
App.vue
//其他自定义组件
从“Vue”导入Vue;
从“Vuetify”导入Vuetify;
Vue.use(Vuetify);
导出默认值{}
我还尝试了向组件添加名称的修复,但这也没有改变任何东西。只需从App.vue中删除这些导入,并将它们仅保留在index.js中即可。结果证明,它不起作用,因为我安装了两个版本的vue。我删除了第二个版本(它是Vue的旧版本),然后在
index.js
中导入Vuetify工作正常。我仍然不知道为什么Vuetify在App.Vue
中包含Vue的重复版本,而在index.js
中不包含Vue的重复版本,但删除第二个Vue实例为我解决了这个问题。这很奇怪。我将Vuetify包含在main.js
中,它就像一个符咒一样工作。当我将它们放在index.js中时,它停止工作,我想知道为什么?您是否使用vue cli 2.x和网页包模板?您是否使用vue init webpack为我的项目搭建了新项目?不,我没有搭建,我已经安装了vue cli 2.9.6。抱歉,我不知道您做了什么。
import Vue from "vue";
import Vuetify from "vuetify";
import StorePlugin from "./store/index";
import LibrariesPlugin from "./plugins/libraries";
import App from "./components/App";
import 'vuetify/dist/vuetify.min.css'
Vue.use(Vuetify);
Vue.use(StorePlugin);
Vue.use(LibrariesPlugin);
Vue.config.productionTip = false
new Vue({
el: "#app",
render: h => h(App)
});
<template>
<v-app>
// other custom components
</v-app>
</template>
<script>
import Vue from "vue";
import Vuetify from "vuetify";
Vue.use(Vuetify);
export default {}
</script>