Javascript “Not a Constructor” Exception while creating objects

后端 未结 14 1248
[愿得一人]
[愿得一人] 2020-11-27 18:15

I am defining an object like this:

function Project(Attributes, ProjectWidth, ProjectHeight)
{
    this.ProjectHeight = ProjectHeight;
    this.ProjectWidth          


        
14条回答
  •  心在旅途
    2020-11-27 18:43

    For me it was the differences between import and require on ES6.

    E.g.

    // processor.js
    class Processor {
    
    }
    
    export default Processor
    
    //index.js
    const Processor = require('./processor');
    const processor = new Processor() //fails with the error
    
    import Processor from './processor'
    const processor = new Processor() // succeeds
    

提交回复
热议问题