zoukankan      html  css  js  c++  java
  • 常用的设计模式

    常用的设计模式
    `

            let TankFactor = {
            tankList: {
                "01": function() {
                    const img = new Image(); 
                    img.src = "./images/01.jpg";
                    return img;
                },
                "02": function() {
                    const img = new Image(); // 创建一张图片
                    img.src = "./images/02.jpg";
                    return img;
                },
                "03": function() {
                    const img = new Image(); 
                    img.src = "./images/03.jpg";
                    return img;
                },
                "04": function() {
                    const img = new Image(); 
                    img.src = "./images/04.jpg";
                    return img;
                }
            },
            create: function(type) { // 通过create来创建坦克 
                let info = this.tankList[type]();    // this.tankList['01']
                return info;
            }
        }
        let v1 = TankFactor.create('02');
        document.body.appendChild(v1);
    
    
  • 相关阅读:
    处处留心皆学问,世事如棋局局新…
    【转载】2017 软件测试行业现状调查报告_From_51testing_On_20180625
    Hello World In Go ...
    C# 易错题整理
    C# 函数
    C# 哈希表,队列,栈
    C# 数组,集合,泛型集合
    C# 如何生成验证码
    C# 年月日时间题+Timespan
    闰年的一个BUG
  • 原文地址:https://www.cnblogs.com/lyly96720/p/12526840.html
Copyright © 2011-2022 走看看