Vue2使用monaco-editor

avatar
作者
猴君
阅读量:0

之前写了一篇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

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!