这是test.html文件中的html代码片段。
<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>
这是我系统上的一个文件树。
ide ├── cpp14 │ ├── test.html ├── monaco └── node_modules ├── monaco-editor └── test.html
我将test.html文件从monaco/node_moules/复制到cpp14
并将cpp14/test.html中的所有路径更改为
<script src="ide/monaco/node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'ide/monaco/node_modules/monaco-editor/min/vs' }});
require(['ide/monaco/node_modules/monaco-editor/min/vs/editor/editor.main'], function() {
var editor = monaco.editor.create(document.getElementById('container'), {
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
});
});
这不起作用,我认为在代码片段中设置这些文件的路径时存在错误。如何做到这一点呢?
发布于 2017-12-12 05:40:42
尝试为其添加别名:
require.config({
paths:{
'ide/monaco/node_modules/test.html': 'ide/cpp14/test.html'
'vs': '...'
}
});https://stackoverflow.com/questions/46220694
复制相似问题