如何使用requirejs从CDN加载ace编辑器主题? [英] How to load ace editor theme from CDN with requirejs?

查看:43
本文介绍了如何使用requirejs从CDN加载ace编辑器主题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 requirejs 从 CDN 加载 ace 主题.

I am trying to load an ace theme from a CDN with requirejs.

这里 是一个 plunkr,它说明了我的问题.在以下情况下找不到主题:

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
})

注意:我问了这个问题从 CDN 加载带有 requirejs 的 ace 编辑器,但它没有解释如何加载 ace 主题.

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.

推荐答案

好像ace有bug,需要调用

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"))

ace.edit之前配置路径.

这篇关于如何使用requirejs从CDN加载ace编辑器主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆