Vue CLI 5.x环境下能否使用Vuetify 3?安装后报错问题咨询
Short answer: Yes, Vuetify 3 is designed explicitly for Vue 3, so it should work seamlessly with Vue CLI 5. The errors you're seeing are almost certainly due to a misstep during setup, not an inherent incompatibility.
Let’s break down common issues and fixes to get your project running:
Double-check your Vuetify installation command
If you ranvue add vuetifywithout specifying the version, it might have installed Vuetify 2 (which only supports Vue 2) by default. For Vue 3, you need to install the Vuetify 3 beta/stable build using:vue add vuetify@nextVerify your project’s Vue version
Open yourpackage.jsonand ensure thevuedependency is listed as^3.x.x. Vue CLI 5 does support Vue 3, but it’s possible your project was initialized with Vue 2 accidentally. If so, you’ll need to either migrate the project to Vue 3 or switch to Vuetify 2.Fix your Vuetify plugin configuration
Vuetify 3 uses a different initialization pattern than Vuetify 2. Make sure yoursrc/plugins/vuetify.jslooks like this:import { createApp } from 'vue' import { createVuetify } from 'vuetify' import 'vuetify/styles' // Don't forget global styles const vuetify = createVuetify() createApp(App).use(vuetify).mount('#app')If your config still references
Vue.use(Vuetify)or older syntax, that’s a sign you’re using Vuetify 2 instead of 3.Resolve missing peer dependencies
Vuetify 3 requires specific peer dependencies (like@mdi/fontfor icons, orvue-routerif using routing). Runnpm installagain to ensure all dependencies are installed, or check your error logs for mentions of missing packages to install them manually.Rule out conflicting plugins
Some older Vue plugins might not be compatible with Vue 3 or Vuetify 3. Try temporarily disabling other plugins in your project to see if the error disappears, then update or replace any incompatible ones.
As a reference, the Vuetify documentation previously stated:
当前版本的Vuetify不支持Vue 3,对Vue 3的支持将随Vuetify v3版本的发布而提供。创建新项目时,请确保在Vue CLI的提示中选择了Vue 2,或安装到已有的Vue 2项目中。
This note applies to pre-Vuetify 3 versions. Now that Vuetify 3 is officially released, it’s fully compatible with Vue 3 and Vue CLI 5.
内容的提问来源于stack exchange,提问作者Darwin

