简体   繁体   中英

Client-side javascript error: Uncaught ReferenceError: require is not defined

I'm trying to create a new Range object in Ace Editor. I've found numerous examples prescribing the following:

var Range = require("ace/range").Range;
var newRange = new Range(0, 0, 0, 10);

But when I try this I get the following error:

Uncaught ReferenceError: require is not defined

I'm loading the Ace Editor JS in a script tag in a Rails view:

<script src="/js/ace_editor/ace.js" type="text/javascript" charset="utf-8"></script>

如果您使用的是无冲突版本,则需要使用ace.require而不是require,因为no-conflict不会创建全局require且不会与require的其他不兼容实现冲突,因此可能会加载到页面上。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM