码迷,mamicode.com
首页 > 其他好文 > 详细

es6 添加事件监听

时间:2016-05-31 12:15:34      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:

//定义被侦听的目标对象
var engineer = { name: Joe Sixpack, salary: 50 };

//定义处理程序
var interceptor = {
    set: function (receiver, property, value) {
        console.log(property, is changed to, value);
        receiver[property] = value;
    }
};

//创建代理以进行侦听
new Proxy(engineer, interceptor);
//做一些改动来触发代理
engineer.salary = 60;//控制台输出:salary is changed to 60
engineer.salary = 50;//控制台输出:salary is changed to 60

 

es6 添加事件监听

标签:

原文地址:http://www.cnblogs.com/liujinyu/p/5545207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!