示例代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" /> </head> <body> <div id="editor" style="width: 500px; height: 300px;"></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ace/ace.js"></script> <script> // 初始化编辑器 const editor = ace.edit("editor"); editor.setTheme("ace/theme/monokai"); editor.session.setMode("ace/mode/javascript"); // 示例代码 editor.setValue(`function hello() { console.log("Hello World"); } // 这是一条注释 const message = "Ace.js 选择示例";`); // 监听选择事件 editor.getSelection().on("changeSelection", () => { const range = editor.getSelectionRange(); // 开始行和结束行(转为人类可读的 1 基索引) const start = range.start.row + 1; const end = range.end.row + 1; console.log(`选中范围:第 ${start} 行 - 第 ${end} 行`); }); </script> </body> </html>
网友回复
win10如何修改机器码?
python结合ffmpeg如何实现窗口实现视频格式转换压缩、分离音频,合并字幕及音频?
Pogocache比redis更快更好用?
新手如何使用yolo进行图像数据标注与图像识别?
threejs如何将glb三维模型减少面数和定点数粗糙一些减少文件体积大小?
在哪可以免费下载各国的武器飞机坦克航母舰艇导弹三维模型glb文件?
aistudio中build如何破解gemini的api模型调用免费使用?
python如何让红绿灯看懂两侧车流智能调节红绿灯?
python+faster_whisper如何实现实时开会录音并转成文字?
python如何调用微信本地的ocr进行图片文字提取?