2017-09-14 82 views
0

这是一个test.html文件中的html代码片段。如何在摩纳哥编辑器中设置文件的路径?

<script src="monaco-editor/min/vs/loader.js"></script> 
 
<script> 
 
\t require.config({ paths: { 'vs': 'monaco-editor/min/vs' }}); 
 
\t require(['vs/editor/editor.main'], function() { 
 
\t \t var editor = monaco.editor.create(document.getElementById('container'), { 
 
\t \t \t value: [ 
 
\t \t \t \t 'function x() {', 
 
\t \t \t \t '\tconsole.log("Hello world!");', 
 
\t \t \t \t '}' 
 
\t \t \t ].join('\n'), 
 
\t \t \t language: 'javascript' 
 
\t \t }); 
 
\t }); 
 
</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> 
 
\t require.config({ paths: { 'vs': 'ide/monaco/node_modules/monaco-editor/min/vs' }}); 
 
\t require(['ide/monaco/node_modules/monaco-editor/min/vs/editor/editor.main'], function() { 
 
\t \t var editor = monaco.editor.create(document.getElementById('container'), { 
 
\t \t \t value: [ 
 
\t \t \t \t 'function x() {', 
 
\t \t \t \t '\tconsole.log("Hello world!");', 
 
\t \t \t \t '}' 
 
\t \t \t ].join('\n'), 
 
\t \t \t language: 'javascript' 
 
\t \t }); 
 
    });

这不是工作,我认为有是错误的在代码片段中设置这些文件的路径。 如何使这项工作?

回答

0

尝试走样它:

require.config({ 
    paths:{ 
     'ide/monaco/node_modules/test.html': 'ide/cpp14/test.html' 
      'vs': '...' 
    } 
});