闭包编译器错误:JSC_NOT_A_CONSTRUCTOR
Closure Compiler Error: JSC_NOT_A_CONSTRUCTOR
我在玩闭包编译器,并放入以下代码:
var obj = (function() {
function H(a) {
this.a = a
}
var h = new H(1);
h.b=1
return h
})();
我想看看它是否会把它转换成这样:
var obj = (function() {
function H(a) {
this.a = a;
this.b = 1
}
var h = new H(1);
return h;
})();
但是我得到了这个错误JSC_NOT_A_CONSTRUCTOR: cannot instantiate non-constructor at line 6 character 8
var h = new H(1);
我做错了什么?
您必须通过@constructor
:告诉CC函数是构造函数
/**
* Makes an H.
* @constructor
*/
function H() {
...
}
相关文章:
- jQuery is not loaded
- AngularJS JSON not arriving php
- $rootScope not working
- reactRedux is not defined
- jQuery document.ready not working
- Javascript/Jquery Blob not showing Chrome PDF
- ReferenceError: not defined
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- Javascript getElementsByTagName not working?
- jQuery's trim()的前缀为not运算符
- Javascript - element.childNodes does not see an append.newch
- SemanticUI模态not onDeny/onApprove事件未激发
- WebkitTransform not fluent
- JQuery.val( ) not working
- Tomcat websocket is not working
- :not选择器不适用于ul类-备选方案
- Javascript JSON.parse not working
- NodeJS Multer is not working
- React, Webpack: bundle.js is not generated
- AngularJS ng-init does not work