PrefaceMy needs are syntax highlighting, function prompts, automatic line wrapping, and code folding. Monaco Monaco is from Microsoft, it supports many languages and has thumbnail maps, but sometimes the prompts are not easy to use and the package size is very large. How to use official website
Install
Introduction import * as monaco from 'monaco-editor' // The package is big but the demo can run // Customize some suggestion functions const suggestions = [ { label: 'split_chinese', insertText: 'split_chinese(inputString,language);', // Not displayed when not written. . Details: 'inputString: need split string\n' + 'language:\nCH_T:traditional Chinese\nCH_S:Chinese Simplified\n HK_T:Hong Kong Traditional\nTW_T:Taiwan Traditional\n' }, { label: 'uuid', insertText: 'var uuid = uuid();', detail: 'generate uuid' }, { label: 'HashMap', insertText: 'var hashMap = new HashMap();', detail: 'create hash object' } ] initialization mounted() { monaco.languages.registerCompletionItemProvider('JavaScript', { provideCompletionItems() { return { suggestions: suggestions } }, triggerCharacters: [' ', '.'] // Write the characters that trigger the prompt, there can be multiple }) let self = this setTimeout(function () { self.init() }, 50) //Because the parent component has not passed the parameter, the child component has been rendered} // Initialization method init(script) { let self = this if (script) this.code = script self.$refs.container.innerHTML = '' var editor = monaco.editor.create(this.$refs.container, { value: this.code, language: 'javascript', minimap: enabled: false }, fontSize: '12px', fixedOverflowWidgets: true // Use fixed attributes to display widgets that exceed the editor size}) editor.onDidChangeModelContent(function () { self.$emit('update:code', editor.getValue()) //Used to monitor editor content changes and pass the content to the parent component}) } html <template> <div ref="container" class="monaco"></div> </template> CSS <style scoped> .monaco { width: 95%; height: 400px; border: 1px solid #dcdfe6; text-align: left; margin-right: 20px; border-radius: 4px; } </style> Operation effect shortcoming Mine was overturned and I don't want to run it again. I'll just write a demo while the code is still there. It runs OK (some customers also reported that it is not easy to use, it is my own fault, I am not worthy of using Monaco). However, it is really difficult to use, especially the prompt function, which usually does not have any prompts. Then one package was huge, like 3.9G (seriously). It may not be introduced as needed, but if it is not introduced, there will be no prompt function, custom function prompt. There is also webpack configuration, tossing back and forth! The above is the detailed content of the tutorial on how to use the JS compiler Monaco. For more information about the JS compiler Monaco, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Detailed tutorial for installing mysql 8.0.12 under Windows
>>: Detailed steps to change the default password when installing MySQL in Ubuntu
When changing the time zone under Linux, it is al...
Example: tip: This component is based on vue-crop...
Table of contents 1. Comments on MySQL primary ke...
Table of contents 1. What is deconstruction? 2. A...
When we use the like % wildcard, we often encount...
1. Usage scenarios There is such a requirement, s...
What is a mata tag The <meta> element provi...
In the actual project development process, the pag...
The article mainly records the simple installatio...
1.MySQL multiple instances MySQL multi-instance m...
In this article, we will learn about the optimiza...
This article collects 20 excellent web page color ...
The operating environment of this tutorial: Windo...
<br />Looking at this title, you may find it...
Preface This article summarizes some implementati...