zoukankan      html  css  js  c++  java
  • AMD&CMD

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    </head>
    
    <body>
    
    <script>
    ;(function(root, factory) {
      if (typeof module !== 'undefined' && module.exports) {// CommonJS
        module.exports = factory();
      } else if (typeof define === 'function' && define.amd) {// AMD / RequireJS
        define(factory);
      } else {
        root.Promise = factory.call(root);
      }
    }(this, function() {
      'use strict';
    
      function PromiseA(resolver) {
        return this;
      }
      
      // new Promise().a()
      PromiseA.prototype.a = function () {
        console.log('a');
    
        return this;
      };
    
      PromiseA.prototype.b = function () {
        console.log('b');
    
        return this;
      };
      
      // Promise.a()
      PromiseA.a = function () {
        var p = new PromiseA();
    
        return p.a();
      };
    
      PromiseA.b = function () {
        var p = new PromiseA();
    
        return p.b();
      };
      
      return PromiseA;
    }));
    
    new Promise().a().b();
    
    Promise.a().b();
    </script>
    </body>
    
    </html>
  • 相关阅读:
    抽象工厂模式
    工厂方法模式
    简单工厂模式
    Zuul
    Turbine
    Hystrix
    Feign
    Ribbon
    Eureka
    @MappedSuperclass的作用
  • 原文地址:https://www.cnblogs.com/baie/p/4881541.html
Copyright © 2011-2022 走看看