首页 > Web开发 > 详细

JS 代理模式

时间:2016-06-07 12:37:55      阅读:246      评论:0      收藏:0      [点我收藏+]
<!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>

  

JS 代理模式

原文:http://www.cnblogs.com/yqlog/p/5566479.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!