我正在尝试用需求从CDN加载ace编辑器。
这里是一个说明我问题的柱塞。在以下情况下未定义Ace:
requirejs.config({
paths: { ace: ['//cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace'] }
})
$('h1').text("loading ace...");
requirejs([ 'ace'], function(ace) {
$('h1').text("ace loaded.")
console.log(ace)
ace.edit('#editor')
return
})发布于 2015-06-17 18:49:43
您需要将ace定义为包含ace.js并要求"ace/ace“的文件夹的路径。
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)
ace.edit('editor')
})<!DOCTYPE html>
<html>
<head>
<script src="http://requirejs.org/docs/release/2.1.14/minified/require.js"></script>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<h1>Hello Plunker!</h1>
<div id='editor' style="height:200px"></div>
</body>
</html>
https://stackoverflow.com/questions/30888155
复制相似问题