说起来挺坑的,Vue 2.x 和 3.x 好多地方不兼容。
而网上好多教程,视频都是以 Vue2.x 为基准做的。
然后就悲催的发现各种不调。
比如标题的这个错误:
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
at eval (types.js:39:1)
at ./node_modules/element-ui/lib/utils/types.js (chunk-vendors.js:202:1)
at __webpack_require__ (app.js:358:33)
at fn (app.js:591:21)
at eval (util.js:19:1)
at ./node_modules/element-ui/lib/utils/util.js (chunk-vendors.js:213:1)
at __webpack_require__ (app.js:358:33)
at fn (app.js:591:21)
at eval (migrating.js:5:1)
at ./node_modules/element-ui/lib/mixins/migrating.js (chunk-vendors.js:169:1)
就是写下面这个代码的时候出的错误:
其实呢,我试了前两个,是没错的,我怎么也没理解element-ui怎么会没有 Input组件:)
import { createApp } from 'vue'
import App from '../App.vue'
import { Button, Form, Input } from 'element-ui'
createApp(App).use(Button, Form, Input)
错误的原因是 element-ui 只支持 Vue2.x,而想用Vue3.x及以上,比如Vue5.x,那就要用element-plus。
>You’re browsing the documentation of Element UI for Vue 2.x version. Click here for Vue 3.x version
<参考>
1,黑马程序员 Vue 前端开发
2,问题:用vue-cli3.x创建项目 引入element时无法显示组件