`var Sigleton = cc.Class({
properties: {
_Instance:null,
},
statics:{
getInstance( subClass ){
if( null === this._Instance ){
this._Instance = new subClass( )//新建对象时会调用父类构造函数
}
return this._Instance
}
},
ctor( object ){
if( this._Instance !== null ){
cc.log( "===实例化异常===" )
}
this.InitObj( )
},
//虚函数
InitObj( ){
cc.log( '=========SIgleTon Init======' )
},
});
module.exports = Sigleton`
var Sigleton = require( 'Sigleton' ) console.log( 'Sigleton',Sigleton )
输出结果是

这是什么情况,即使我写成
Sigleton.getInstance = function( subClass ){ if( null === this._Instance ){ this._Instance = new subClass( )//新建对象时会调用父类构造函数 } return this._Instance }
还是没有getInstance方法