vue使用monaco?editor漢化右鍵菜單示例
安裝依賴插件
首先使用npm或者其他包管理工具安裝依賴插件:
npm install monaco-editor --save npm install monaco-editor-nls --save npm install monaco-editor-webpack-plugin --save npm install monaco-editor-esm-webpack-plugin --save-dev
推薦安裝的依賴版本對(duì)應(yīng):package.json
{ "dependencies": { "monaco-editor": "^0.20.0", "monaco-editor-nls": "^2.0.0", "monaco-editor-webpack-plugin": "^1.9.1", }, "devDependencies": { "monaco-editor-esm-webpack-plugin": "^2.0.0" } }
webpack.config.js 添加配置:(此處使用vue-cil3.0 配置在vue.config.js里面)
const MonacoWebpackPlugin = require('monaco-editor-esm-webpack-plugin'); module.exports = { configureWebpack: { module: { rules: [{ test: /\.js/, enforce: 'pre', include: /node_modules[\\\/]monaco-editor[\\\/]esm/, use: MonacoWebpackPlugin.loader }] }, plugins: [ new MonacoWebpackPlugin() ] } }
此處需要引入monaco-editor-esm-webpack-plugin,引入monaco-editor-webpack-plugin無(wú)法漢化成功設(shè)置語(yǔ)言包
// 漢化 monaco import { setLocaleData } from "monaco-editor-nls" import zh_CN from "monaco-editor-nls/locale/zh-hans" setLocaleData(zh_CN) //先漢化語(yǔ)言,再加載monaco才能漢化成功,使用import方式無(wú)法漢化 //需要使用require方式引入monaco-editor //import * as monaco from 'monaco-editor' const monaco = require("monaco-editor/esm/vs/editor/editor.api");
設(shè)置完以上配置后,漢化成功效果如下:
以上就是vue使用monaco editor漢化右鍵菜單示例的詳細(xì)內(nèi)容,更多關(guān)于vue右鍵菜單漢化的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
vue 2.8.2版本配置剛進(jìn)入時(shí)候的默認(rèn)頁(yè)面方法
今天小編就為大家分享一篇vue 2.8.2版本配置剛進(jìn)入時(shí)候的默認(rèn)頁(yè)面方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09vue表單綁定實(shí)現(xiàn)多選框和下拉列表的實(shí)例
本篇文章主要介紹了vue表單綁定實(shí)現(xiàn)多選框和下拉列表的實(shí)例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-08-08vue中el-table實(shí)現(xiàn)無(wú)限向下滾動(dòng)懶加載數(shù)據(jù)
一次性的加載全部的數(shù)據(jù),并且將其渲染到頁(yè)面上,就會(huì)導(dǎo)致頁(yè)面卡頓,往往采用分頁(yè)和無(wú)限滾動(dòng)的方式來(lái)展示,本文主要介紹了vue中el-table實(shí)現(xiàn)無(wú)限向下滾動(dòng)懶加載數(shù)據(jù),感興趣的可以了解一下2023-12-12vue實(shí)現(xiàn)下拉加載其實(shí)沒(méi)那么復(fù)雜
這篇文章主要給大家介紹了關(guān)于vue實(shí)現(xiàn)下拉加載的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08vue如何從后臺(tái)獲取數(shù)據(jù)生成動(dòng)態(tài)菜單列表
這篇文章主要介紹了vue如何從后臺(tái)獲取數(shù)據(jù)生成動(dòng)態(tài)菜單列表,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-04-04