惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
Help Net Security
Help Net Security
P
Proofpoint News Feed
J
Java Code Geeks
爱范儿
爱范儿
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
Google DeepMind News
Google DeepMind News
H
Help Net Security
G
Google Developers Blog
Jina AI
Jina AI
Vercel News
Vercel News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
Lohrmann on Cybersecurity
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
GbyAI
GbyAI
B
Blog
O
OpenAI News
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
C
Cisco Blogs
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
AI
AI
W
WeLiveSecurity
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale

虹墨空间站

浏览器直接访问正常,过了负载均衡就崩了?只因响应头里多了个空格 Claude Code 怎样快速消耗 token 去掉高德地图开屏广告 解决 Claude Code 安装或更新后 claude.exe 无法运行、claude native binary not installed Windows 11 26H1 显示所有托盘图标 OpenClaw 安装与配置 盘点手里的电子产品传家宝 基于 7z 的 NAS 到网盘备份解决方案,支持增量、分卷、加密、压缩 卸载百度网盘智能看图 在线工具 - 富文本转 Markdown 2025 年了,安卓平板上什么第三方九键输入法最好用? 鸿蒙 PC 编译运行 Electron 应用 bat 脚本打印输出彩色文字 Android 强制锁定屏幕旋转方向
CDN 方式引入 Monaco Editor
iMaeGoo · 2025-09-01 · via 虹墨空间站

在前端工程中可以用 @monaco-editor/loader 来引入 Monaco,但有时候我们的前端项目不依赖 Webpack、Vite 等打包工具,如何在普通网页中用纯 CDN 的方式引入 Monaco Editor?

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<title>Monaco Editor</title>
<style>
body {
margin: 0;
padding: 0;
}
#editor {
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<div id="editor"></div>
<script src="https://registry.npmmirror.com/monaco-editor/0.52.2/files/min/vs/loader.js"></script>
<script>
require.config({
paths: {
vs: "https://registry.npmmirror.com/monaco-editor/0.52.2/files/min/vs",
},
});
window.MonacoEnvironment = {
getWorkerUrl: function (workerId, label) {
return `data:text/javascript;charset=utf-8,${encodeURIComponent(
'self.MonacoEnvironment={baseUrl:"https://registry.npmmirror.com/monaco-editor/0.52.2/files/min/"};' +
'importScripts("https://registry.npmmirror.com/monaco-editor/0.52.2/files/min/vs/base/worker/workerMain.js");'
)}`;
},
};
require(["vs/editor/editor.main"], function () {
const editorElement = document.getElementById("editor");
const editor = monaco.editor.create(editorElement, {
value:
"function main() {\n console.log('Hello, iMaeGoo!');\n}\n\nmain();\n",
language: "javascript",
});
window.addEventListener("resize", () =>
editor.layout({
width: editorElement.offsetWidth,
height: editorElement.offsetHeight,
})
);
});
</script>
</body>
</html>

效果