相关疑难解决方法(0)

Javascript"Not a Constructor"创建对象时出现异常

我正在定义一个这样的对象:

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

    this.currentLayout = '';

    this.CreateLayoutArray = function()
    {....}
}
Run Code Online (Sandbox Code Playgroud)

然后我尝试创建和实例像这样:

var newProj = new Project(a,b,c);
Run Code Online (Sandbox Code Playgroud)

但是这个例子被抛出:

Project is not a constructor
Run Code Online (Sandbox Code Playgroud)

可能有什么不对?我搜索了很多,但仍然无法弄清楚我做错了什么.

javascript constructor object typeerror

87
推荐指数
12
解决办法
21万
查看次数

标签 统计

constructor ×1

javascript ×1

object ×1

typeerror ×1