How is SAP UI5 Aggregation designed

  • 2019 年 10 月 6 日
  • 筆記

版權聲明:本文為部落客原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。

本文鏈接:https://jerry.blog.csdn.net/article/details/101018261

我的sample code: 最後是framework debug

<html>  <script>    function Aggregation(name) {  this.mAggregationName = name;  }    var oItemAgg = new Aggregation("item"); // so far, Aggregation oject has no available method    debugger;    Aggregation.prototype.generate = function(add, prototype) {  var that = this, n = that.mAggregationName;    add("getAggregation", prototype, function() {  console.log(" getAggregation should be implemented here!");  });  }    function add(name, proto, fn){  if ( !proto[name] ) {  proto[name] =  fn;  }  }    oItemAgg.generate(add, Aggregation.prototype);    oItemAgg.getAggregation();    debugger;  </script>

這裡的bindItem實際上不是一個function,而是Javascript對象的一個attribute,該attribute指向了一個匿名函數,其實現是 this.bindAggregation(n, o, t, s,f)

Tags: