vue3关于"export 'default' (imported as 'Vue') was not found in 'vue'

Vue3项目注册全局组件时使用Vue时报错"export 'default' (imported as 'Vue') was not found in 'vue'

报错信息截图

原因:vue3中没有全局的vue

解决方法:使用createApp

//引入createApp
import { createApp } from 'vue'
//引入需要添加的组件
import Icon from "@/components/Icon.vue";
//添加组件
createApp().component('Icon', Icon)

//如果在main.js中

createApp(App).use(store).use(router).component('Icon', Icon).mount('#app')
修改成功截图

已解决

你可能感兴趣的:(vue3关于"export 'default' (imported as 'Vue') was not found in 'vue')