1 Star 0 Fork 0

animalcoder/Vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ProxyHandler.js 787 Bytes
一键复制 编辑 原始数据 按行查看 历史
animalcoder 提交于 2020-03-17 14:52 +08:00 . Vueinit
module.exports = ProxyHandler;
function ProxyHandler(cbs) {
this._cbs = cbs || {};
}
var EVENTS = require("./").EVENTS;
Object.keys(EVENTS).forEach(function(name) {
if (EVENTS[name] === 0) {
name = "on" + name;
ProxyHandler.prototype[name] = function() {
if (this._cbs[name]) this._cbs[name]();
};
} else if (EVENTS[name] === 1) {
name = "on" + name;
ProxyHandler.prototype[name] = function(a) {
if (this._cbs[name]) this._cbs[name](a);
};
} else if (EVENTS[name] === 2) {
name = "on" + name;
ProxyHandler.prototype[name] = function(a, b) {
if (this._cbs[name]) this._cbs[name](a, b);
};
} else {
throw Error("wrong number of arguments");
}
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/animalcoder/Vue.git
git@gitee.com:animalcoder/Vue.git
animalcoder
Vue
Vue
master

搜索帮助