jQuery订阅发布消息模式的回调函数中传入参数值,找javascript高手求解啊!!!
相关代码如下:<scripttype="text/javascript">(function($){varo=$({});$.subscribe=function(){o...
相关代码如下:
<script type="text/javascript">(function($) {
var o = $({}); $.subscribe = function() { o.bind.apply(o, arguments); }; $.unsubscribe = function() { o.unbind.apply(o, arguments); }; $.publish = function() { o.trigger.apply(o, $.makeArray(arguments)); };})(jQuery);//订阅$.subscribe("test", function(e, a1, a2, a3, a4) { alert(e.type + "," + a1 + "," + a2 + "," + a3 + "," + a4);});
//发布$.publish("test", "a", "bds", "csdf", "dsdf");</script>
打印结果如下:
如图,能够获取事件名参数和第一个形参a1的值,却不能获取a2,a3,a4的值,求解原因啊。
(注:此代码摘自 《基于javascript web富应用开发》,书中讲解是可以取到对应参数值的) 展开
<script type="text/javascript">(function($) {
var o = $({}); $.subscribe = function() { o.bind.apply(o, arguments); }; $.unsubscribe = function() { o.unbind.apply(o, arguments); }; $.publish = function() { o.trigger.apply(o, $.makeArray(arguments)); };})(jQuery);//订阅$.subscribe("test", function(e, a1, a2, a3, a4) { alert(e.type + "," + a1 + "," + a2 + "," + a3 + "," + a4);});
//发布$.publish("test", "a", "bds", "csdf", "dsdf");</script>
打印结果如下:
如图,能够获取事件名参数和第一个形参a1的值,却不能获取a2,a3,a4的值,求解原因啊。
(注:此代码摘自 《基于javascript web富应用开发》,书中讲解是可以取到对应参数值的) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询