问题
I am trying to load an ace theme from a CDN with requirejs.
Here is a plunkr which illustrates my problem. The theme can not be found in the following case:
requirejs.config({
paths: { ace: ['//cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/'] }
})
$('h1').text("loading ace...");
requirejs([ 'ace/ace'], function(ace) {
$('h1').text("ace loaded.")
console.log(ace)
editor = ace.edit('editor')
editor.setTheme("ace/theme/monokai")
return
})
Note: I asked this question to load ace editor with requirejs from CDN, but it does not explain how can I load an ace theme.
回答1:
Seems like there is a bug in ace, and one needs to call
ace.config.set("packaged", true)
ace.config.set("basePath", require.toUrl("ace"))
before ace.edit
to configure paths.
来源:https://stackoverflow.com/questions/31211331/how-to-load-ace-editor-theme-from-cdn-with-requirejs