为了账号安全,请及时绑定邮箱和手机立即绑定

请问这是什么问题,是事件冒泡造成的吗?

//添加jQuery模块依赖

require.config({//require自带config方法可以把文件名和映射的模块名相关联

paths:{jquery:'jquery.min',

jqueryUI:'jquery-ui.min'

}

});

require(['jquery','window'],function($,w){

$("#a").click(function(){

var win=new w.Window().alert({

title:"提示",

content:"welcome!",

handler:function(){

alert("You click the button");

},

width:300,

height:150,

y:50,

hasCloseBtn:true,

text4AlertBtn:"OK",

dragHandle:".window_header",

skinClassName:"window_skin_a",

handler4AlertBtn:function(){

alert("you click the alert button");

},

handler4CloseBtn:function(){

alert("you click the close button");

}

}).on("alert",function(){

alert("the second alert handler");

}).on("close",function(){

alert("the second close handler");

});

win.on("alert",function(){

alert("the third alert handler");

});

});

});

如上述代码琐示,除了自己加了皮肤skinClassName这个参数外其余和老师一模一样

问题出现在:

handler4AlertBtn:function(){

alert("you click the alert button");

},

handler4CloseBtn:function(){

alert("you click the close button");

}

当点击alert(OK按钮)时,出现了:you click the alert button ,you click the alert button,the second alert handler,the third alert handler看似和老师的一样但是明显的是you click the alert button多出现了1次,同样当点击关闭(close)按钮时也出现了:you click the close button,you click the close button,the second close handler即多出现了一次you click the close button,请问是什么原因?

正在回答

1 回答

调用了两次



0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
阿当大话西游之WEB组件
  • 参与学习       26365    人
  • 解答问题       278    个

衡量攻城师能力是否成熟的重要指标,本课程会以弹窗组件为例

进入课程

请问这是什么问题,是事件冒泡造成的吗?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号