0
点赞
收藏
分享

微信扫一扫

Vue2使用monaco-editor

Gaaidou 2024-08-03 阅读 28

之前写了一篇vue3使用monaco-editor的博文(Vue3使用Monaco-editor),vue3中使用过程很顺利,没发现什么问题。但是在vue2中使用碰到一些坑。不过最后总算是搞出来能用了。

首先跟vue3一样,安装monaco-editor、monaco-editor-webpack-plugin这两个插件。vue3里面呢直接安装最新的就行了,但是在vue2中对版本有要求,不能太高了,经过最后的测试,monaco-editor使用0.31.1的版本,monaco-editor-webpack-plugin使用monaco-editor-webpack-plugin使用6.0.0的版本

安装: 

cnpm i monaco-editor@0.31.1
cnpm i monaco-editor-webpack-plugin@6.0.0 -D

配置: 

然后在vue.config.js中配置:

const { defineConfig } = require('@vue/cli-service')
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')

module.exports = defineConfig({
  configureWebp
举报

相关推荐

0 条评论