qianwenshengsec 2021-10-16 21:58 采纳率: 80%
浏览 316
已结题

vue脚手架4.5 引入element-plus按照官方配置报错怎么解决

#项目是Vue3.0 用的vue-cli4.5
#以下是main.js

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

const app = createApp(App);
app.use(ElementPlus).use(store).use(router).mount('#app')

#控制台报如下错误

 ERROR  Failed to compile with 1 error                                                                                                                                      下午9:52:45
 error  in ./node_modules/async-validator/dist-web/index.js

Module parse failed: Unexpected token (847:18)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| class Schema {
|   // ========================= Static =========================
>   static register = function register(type, validator) {
|     if (typeof validator !== 'function') {
|       throw new Error('Cannot register a validator by type, validator is not a function');

 @ ./node_modules/element-plus/es/components/form/index.js 6:0-45 453:28-42
 @ ./node_modules/element-plus/es/components/index.js
 @ ./node_modules/element-plus/es/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.1.228:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

  • 写回答

3条回答 默认 最新

  • zhoutm 2021-10-18 13:03
    关注

    我也遇到这个问题,降到beta17就可以了,初步查了一下,是element-plus依赖的async-validator版本引起的,现在卸载elementui-plus 重新安装,看一下package-lock.json里面async-validator版本号是不是变成4.0.7了,如果还是4.0.5得话,你就手工改好了。

        "async-validator": {
          "version": "4.0.7",
          "resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.0.7.tgz",
          "integrity": "sha512-Pj2IR7u8hmUEDOwB++su6baaRi+QvsgajuFB9j95foM1N2gy5HM4z60hfusIO0fBPG5uLAEl6yCJr1jNSVugEQ=="
        },
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 10月30日
  • 已采纳回答 10月22日
  • 创建了问题 10月16日

悬赏问题

  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题