1.首先通过一个函数来实现JS的单继承。使用原型方式来实现继承

 1 (function () {
 2 
 3     $.extend({
 4         oop: {
 5             extend: function (child, father) {
 6                 if (father == null) {
 7                     var father = function () { };
 8                     console.log(this);
 9                     father.prototype = this
10                 }
11                 child.prototype = new father();
12 
13                 child.base = father;
14                 child.prototype.base = child.prototype;
15             }
16         }
17 
18     });
19     window.oop = $.opp;
20 })();
View Code

 

相关文章:

  • 2022-01-19
  • 2021-08-26
  • 2021-12-24
  • 2021-12-05
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-18
  • 2021-11-30
  • 2021-11-01
  • 2021-12-14
  • 2022-12-23
相关资源
相似解决方案