【不容易】代码高亮输入表单
2022/3/5 6:15:12
本文主要是介绍【不容易】代码高亮输入表单,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
所有要用到的js文件:https://pagecdn.com/lib/ace
教程:https://github.com/ajaxorg/ace
自己写了个python编辑器的示例代码如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <style type="text/css"> #editor { width: 600px; height: 400px; position: absolute; line-height: 20px; font-size: 15px; } </style> </head> <body> <div id="editor"></div> <script type="text/javascript" src="https://pagecdn.io/lib/ace/1.4.13/ace.min.js" charset="utf-8"></script> <script type="text/javascript" src="https://pagecdn.io/lib/ace/1.4.13/theme-vibrant_ink.min.js"></script> <script type="text/javascript" src="https://pagecdn.io/lib/ace/1.4.13/mode-python.min.js"></script> <script type="text/javascript"> let editor = ace.edit("editor"); editor.setTheme("ace/theme/vibrant_ink") let PythonScriptMode = ace.require("ace/mode/python").Mode; editor.session.setMode(new PythonScriptMode()); </script> </body> </html>
有一些可以用到的属性和方法:
editor.getValue(); // 获得表单的内容 editor.setValue("code"); // 设置表单的内容 editor.destroy(); // 移除表单 editor.getReadOnly(); // 查看表单的只读状态 editor.setReadOnly(true); // 设置表单为只读,如果是false的话就解除只读
这篇关于【不容易】代码高亮输入表单的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)