When I try to create a Range object in ace.js, an “Illegal Constructor” error is thrown

前端 未结 4 2071
心在旅途
心在旅途 2020-12-30 10:32

I am trying to create a Range object for the ace.js editor in my code, but it\'s not working. It is failing in a way I can\'t figure out. In the Ace documentati

相关标签:
4条回答
  • 2020-12-30 10:51

    This solution var Range = ace.acequire('ace/range').Range; works for me!!!

    Full code: https://stackoverflow.com/a/53387989/630169

    0 讨论(0)
  • 2020-12-30 10:57

    Replace require('ace/range').Range with ace.require('ace/range').Range

    0 讨论(0)
  • 2020-12-30 10:59

    This worked for me:

    import { Range } from "ace-builds"

    0 讨论(0)
  • 2020-12-30 11:01

    Range is a native type is most browsers that you cannot instantiate. I'm not really familiar with Ace, but I'm guessing that they use some sort of namespacing so that you will do something like new Ace.Range().

    Edit: It looks like they are using CommonJS, so you can import the method and alias it however you like:

    var Range = require('ace/range').Range,
        mine = new Range(0,0,10,0);
    
    0 讨论(0)
提交回复
热议问题