運行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 的新特性書寫,應該如下:
再重新打包 npm run dev
完美解決。