运行npm run dev后报错:
export 'Vue' (imported as 'Vue') was not found in 'vue' 并且加载不出页面,查了很久,终于找到原因:
报错信息:
WARNING in ./src/index.js 24:13-16
export 'Vue' (imported as 'Vue') was not found in 'vue' (possible exports: BaseTransition, BaseTransitionPropsValidators, Comment, DeprecationTypes, EffectScope, ErrorCodes, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, TrackOpTypes, Transition, TransitionGroup, TriggerOpTypes, VueElement, assertNumber, callWithAsyncErrorHandling
在index.js中,老版本的写法如下:
import Vue from "vue"; import App from './App.vue'; const vm = new Vue({ el: '#app', render: h => h(App) })
使用的Vue3.x 版本,这样在命令行运行: npm run dev 始终报错: WARNING in ./src/index.js 24:13-16
export 'Vue' (imported as 'Vue') was not found in 'vue'
问题原因是 导入Vue的方式没按Vue3.X 的新特性书写,应该如下:
import { createApp } from 'vue'; import App from './App.vue'; createApp(App).mount('#app')再重新打包 npm run dev
完美解决。
标签:Vue,imported,App,vue,报错,was From: https://www.cnblogs.com/dongtian/p/18042890