簡體   English   中英

如何使用CDN中的requirejs加載ace編輯器?

[英]How to load ace editor with requirejs from CDN?

我正在嘗試使用requirejs從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
})

您需要將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> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM