vue 數組更新大概原理(僅供理解)
阿新 • • 發佈:2017-06-07
pre per res oid class nts bsp while -a
var a = [1,1,4] var arrayProto = Array.prototype; var arrayMethods = Object.create(arrayProto); Object.defineProperty(a, ‘push‘, { value: function(){ var arguments$1 = arguments; // avoid leaking arguments: // http://jsperf.com/closure-with-arguments var i = arguments.length; varargs = new Array(i); while (i--) { args[i] = arguments$1[i]; } var original = arrayProto[‘push‘]; var result = original.apply(this, args); console.log("觸發響應,比如更新視圖"); return result; }, enumerable: true, writable: true, configurable: true });
vue 數組更新大概原理(僅供理解)