2017-09-14 35 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

私はmonaco/node_moules/から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 }); 
 
    });

cpp14/test.html内のすべてのパスを変更エラーですこれらのファイルのパスをスニペットに設定することができます。 この作品を作成するには?

答えて

0

それを試してみてくださいエイリアシング:

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