我是按照这么模式来写的,我就加了个这么一条语句,结果就报错
Construct.prototype = {
init:function(){
}
var single = (function(){
var unique;
function getInstance(){
if( unique === undefined ){
unique = new Construct();
}
return unique;
}
function Construct(){
// ... 生成单例的构造函数的代码
this.init(); //这里会报错。说init函数not a function
}
Construct.prototype = {
init:function(){
}
};
return {
getInstance : getInstance
}
})();
Construct.prototype = {
init:function(){
}
var single = (function(){
var unique;
function getInstance(){
if( unique === undefined ){
unique = new Construct();
}
return unique;
}
function Construct(){
// ... 生成单例的构造函数的代码
this.init(); //这里会报错。说init函数not a function
}
Construct.prototype = {
init:function(){
}
};
return {
getInstance : getInstance
}
})();