bind( fn, [scope], [args], [appendArgs] ) : Function
Create a new function from the provided fn, change this to the provided scope, optionally overrides arguments for the call. (Defaults to the arguments passed by the caller)

从提供的fn中创建一个新的函数,改变this到提供的scope,可选的重写调用参数。(默认为由调用方传递的参数)。

Ext.bind is alias for Ext.Function.bind
Ext.bind是Ext.Function.bind的别名

Parameters
fn : Function
The function to delegate.
去代理的函数

scope : Object (optional)
The scope (this reference) in which the function is executed.
If omitted, defaults to the default global environment object (usually the browser window).
函数执行的scope(this引用)
如果忽略了,默认是默认的全局环境变量(通常浏览器window)

args : Array (optional)
Overrides arguments for the call. (Defaults to the arguments passed by the caller)
重写调用参数(默认为由调用者传递的参数)

appendArgs : Boolean/Number (optional)
if True args are appended to call args instead of overriding, if a number the args are inserted at the specified position
如果true,args被追加到调用参数而不是重写;如果一个数字,args被插入在指定的位置。

appendArgs:
不指定或者false:重写参数
true:追加参数
数字:指定位置插入参数
下面是使用例子:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>定义</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="js/ext4/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="css/icon.css">
<!-- <script type="text/javascript" src="js/ext4/bootstrap.js"></script> -->
<script type="text/javascript" src="js/ext4/ext-all-dev.js"></script> <script type="text/javascript" src="js/ext4/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
//设置命名空间路径
Ext.Loader.setPath('org', './js/org');
Ext.onReady(initFn); /**
* 初始化函数
*/
function initFn(){
console.info('Ext准备完毕~~~');
var doAdd = Ext.bind(function(x,y){
var self = this;
console.info('self:',self);
console.info('self==window:',self==window);
return x+y;
}); var result0 = doAdd(5,6);
console.info('result0:',result0); var doSubtract = Ext.bind(function(x,y){
var self = this;
console.info('self:',self);
console.info('self==window:',self==window);
return x-y;
},{fullName:'张泰松',age:28,address:'杭州市西湖区'}); var result1 = doSubtract(15,9);
console.info('result1:',result1); var doMultiply = Ext.bind(function(x,y){
var self = this;
console.info('self:',self);
console.info('self==window:',self==window);
console.info("arguments:",arguments);
return x*y;
},{fullName:'李超军',age:30,email:'1032160369@qq.com'},[18,8],false); var result2 = doMultiply(16,6);
console.info('result2:',result2); var doDivide = Ext.bind(function(x,y){
var self = this;
console.info('self:',self);
console.info('self==window:',self==window);
console.info("arguments:",arguments);
return x/y;
},{fullName:'武利丹',age:29,email:'1175173151@qq.com'},[4,8],1); var result3 = doDivide(16,2);
console.info('result3:',result3);
/*
appendArgs:
不指定或者false:重写参数
true:追加参数
数字:指定位置插入参数
*/
}
</script>
</head>
<body> </body>
</html>

Ext.bind函数说明的更多相关文章

  1. (十一)socket、connect、bind函数详解

    一.socket函数 1.头文件: #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> 2.函数原型: ...

  2. Javascript中call、apply、bind函数

    javascript在函数创建的时候除了自己定义的参数外还会自动新增this和arguments两个参数 javascript中函数也是对象,call.apply.bind函数就是函数中的三个函数,这 ...

  3. angular.bind() 函数

    angular.bind bind 函数有三个参数, 参一:是一个对象 参二:是一个 function 参三:是用来给参二传参数的,可写可不写,看你心情 参数也可以在调用函数的时候传,也可以当做第三个 ...

  4. jQuery.bind() 函数详解

    bind()函数用于为每个匹配元素的一个或多个事件绑定事件处理函数. 此外,你还可以额外传递给事件处理函数一些所需的数据. 执行bind()时,事件处理函数会绑定到每个匹配元素上.因此你使用bind( ...

  5. call,apply,bind函数

    一.call函数 a.call(b); 简单的理解:把a对象的方法应用到b对象上(a里如果有this,会指向b) call()的用法:用在函数上面 var Dog=function(){ this.n ...

  6. C++ Primer : 第十章 : 泛型算法 之 lambda表达式和bind函数

    一.lambda表达式 lambda表达式原型: [capture list] (parameter list) -> retrue type { function body } 一个lambd ...

  7. 模拟实现兼容低版本IE浏览器的原生bind()函数功能

    模拟实现兼容低版本IE浏览器的原生bind()函数功能: 代码如下: if(!Function.prototype.bind){   Function.prototype.bind=function( ...

  8. bind函数

    bind函数把一个本地协议地址赋予一个套接字 对于网际协议,协议地址是32位的IPv4地址或128位的IPv6与16位的TCP或UDP端口号的组合 int bind ( int sockfd, con ...

  9. js 中的bind函数

    bind是Function.prototype中内置函数 作用是指定函数作用域 代码参考 http://blog.csdn.net/load_life/article/details/7200381 ...

随机推荐

  1. 13-cmake语法-路径设置

    路径设置: 包括头文件路径.库文件路径.库文件名等 INCLUDE_DIRECTORIES 向工程添加多个特定的头文件搜索路径,路径之间用空格分隔,如果路径包含空格,可以使用双引号将它括起来,默认的行 ...

  2. 08-人脸识别-FaceNet-classify.py代码阅读(说明见注释)

    """An example of how to use your own dataset to train a classifier that recognizes pe ...

  3. python 通过scapy获取网卡列表

    python通过scapy 获取网卡列表如下: #coding:utf-8 from scapy.all import * #显示网卡信息 show_interfaces() 运行结果如下:

  4. 微信小程序 vscode 自动保存 保存自动编译 微信开发者工具崩溃

    修改vscode的自动保存延迟时间,将 auto save delay 选项 修改的长一点.

  5. 【Tomcat】系统找不到指定的路径

    确认一下端口防火墙是否开放 没开放就开一下:firewall-cmd --zone=public --add-port=9080/tcp --permanent 然后重启: firewall-cmd ...

  6. 【oracle】截取字符串

    select id,name,substr(dept,1,2) from test; 提取字段dept前两位 substr(string,start,length)

  7. update Select 从查询的结果中更新表

    UPDATE tbl_a a INNER JOIN tbl_b b ON a.arg=b.argSET a.arg2=b.arg2 这个语法即可实现

  8. [RN] 可播放视频的播放器版本

    可播放视频的播放器版本 "react": "16.6.3", "react-native": "0.57.8", &qu ...

  9. django -- ORM查询

    前戏 在我们之前操作ORM中,你也许是启动Django项目,通过地址访问固定的函数,或者在pycharm里的python console里执行,第一种比较麻烦,而且每次都要启动项目,写路由,第二种虽然 ...

  10. SQL之存储过程详细介绍及语法(转)

    1:定义 存储过程(stored procedure)是一组为了完成特定功能的SQL语句集合,经编译后存储在服务器端的数据库中,利用存储过程可以加速SQL语句的执行. 存储过程分为系统存储过程和自定义 ...