当前位置: 代码迷 >> 综合 >> JS设计模式之简单工厂模式
  详细解决方案

JS设计模式之简单工厂模式

热度:15   发布时间:2024-01-24 05:21:22.0
$(function () {
     var userNameAlter=createPopup("alert","验证");
});
function createPopup(type,text){
    var o=new Object();
    o.content=text;
    o.show=function () {
        alert("显示");
    }
    if(type=="alert"){
        o.show();
    }
    if(type=="promot"){
    }
    if(type=="confirm"){
    }
    return o;
}

通过寄生式继承得到纯净的对象,虽然这个模式有很多的不足

  相关解决方案