1. monaco-editor基于瀏覽器的代碼編輯器

        聯(lián)合創(chuàng)作 · 2023-09-23 05:24

        Monaco Editor 是微軟開源的基于 VS Code 的代碼編輯器,運(yùn)行在瀏覽器環(huán)境中。編輯器提供代碼提示,智能建議等功能。供開發(fā)人員遠(yuǎn)程更方便的編寫代碼。描述代碼編輯器功能的頁面在這里

        image

        安裝:

        npm install monaco-editor

        你將會(huì)得到

        • inside dev: bundled, not minified

        • inside min: bundled, and minified

        • inside min-maps: source maps for min

        • monaco.d.ts: this specifies the API of the editor

        集成

        這里是嵌入編輯器最基本的HTML頁面,更多的示例可在monaco-editor-samples找到

        <!DOCTYPE html>
        <html>
        <head>
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
        </head>
        <body>
        
        <div id="container"  ="width:800px;height:600px;border:1px solid grey"></div>
        
        <script src="monaco-editor/min/vs/loader.js"></script><script>    require.config({ paths: { 'vs': 'monaco-editor/min/vs' }});    require(['vs/editor/editor.main'], function() {        var editor = monaco.editor.create(document.getElementById('container'), {            value: [                'function x() {',                '\tconsole.log("Hello world!");',                '}'            ].join('\n'),            language: 'javascript'        });    });</script></body>
        </html>
        瀏覽 36
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        評論
        圖片
        表情
        推薦
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
          
          

            1. 国产在线观看www鲁啊鲁免费 | 教室呻吟用力湿冰山校草 | 大学生一级特黄大片 | 强奸乱伦大杂烩 | 日日操人人操 |