• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • callbacks.fireWith()

    访问给定的上下文和参数列表中的所有回调。

    callbacks.fireWith([context ][, args ])
    • context类型:Anything。该列表中的回调被触发的上下文引用
    • args类型:ArrayLikeObject。一个参数或参数列表传回给回调列表。

    此方法返回绑定它的那个回调对象(this).

    Example

    使用callbacks.fireWith()访问给定的上下文和参数列表中的所有回调:

    // a sample logging function to be added to a callbacks list
    var log = function( value1, value2 ) {
      console.log( "Received: " + value1 + "," + value2 );
    };
     
    var callbacks = $.Callbacks();
     
    // add the log method to the callbacks list
    callbacks.add( log );
     
    // fire the callbacks on the list using the context "window"
    // and an arguments array
     
    callbacks.fireWith( window, ["foo","bar"]);
     
    // outputs: "Received: foo, bar"