标签:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script> /*-------代理模式,A想执行C方法,A调用B间接执行*/ function peopleSing() { this.singSong = function() { var songName = new peopleManageSongs().getSongName(); alert("老子拿到歌了,你妈~~" + songName); }; }; function peopleManageSongs() {} peopleManageSongs.prototype.getSongName = function() { var name = new SongsCreator().getSongName(‘001‘); return name; } function SongsCreator() { this.getSongName = function(number) { switch (number) { case ‘001‘: return "独家记忆"; case ‘002‘: return "空白格"; case "003": return "蓝蓝的天上白云飘"; default: return "我的心好累"; } } this.getVipSongsName = function() { return "这是VIP的歌"; } } var p = new peopleSing().singSong(); </script> </head> <body> </body> </html>
标签:
原文地址:http://www.cnblogs.com/yqlog/p/5566479.html