今天找美工帮我封装了一下js的异步,我js太臭了
<script type="text/javascript">
//顺序必须先收在发
$(document).on('msg',function(e,data){//收
b(data);
});
$(document).trigger('msg',a());//发
$(document).trigger('msg',a2());//发
function a2(){
console.log('a2 log');
return "a2";
}
function a(){
console.log('a log');
return "a";
}
function b(){
console.log(arguments);
}
</script>