vue整合monaco组件
报错信息:
ERROR in ./node modules/monaco-editor/esm/vs/language/typescript/tsMode.js
Module build failed (from ./node modules/babel-loader/lib/index.js):SmntaxEror: D: coadelwetProjectlowmn myoj-infront node modules manaco-editorlesnmvs langlageltypescript tsbode.js: Statitc clas blocks are not enabed. please add &babelplugin-transfom-classtatic-block to your configuration
报错图片如下:
错误的根本原因是因为导入monaco时使用了这个语句:
import * as monaco from "monaco-editor";
解决办法:
1.执行
bash
npm install --save-dev @babel/plugin-transform-class-static-block
命令,下载依赖
2.打开项目babel.config.js文件,加入下面配置
javascript
plugins: ["@babel/plugin-transform-class-static-block"],
如图所示: