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. nginx在linux下安装(源码编译)

    下载 http://nginx.org/en/download.html 安装 安装依赖 yum -y install gcc gcc-c++ zlib zlib-devel pcre-devel o ...

  2. bzoj2187 fraction&&hdu3637 Find a Fraction——类欧几里得

    bzoj2187 多组询问,每次给出 $a, b, c, d$,求满足 $\frac{a}{b}  < \frac{p}{q} < \frac{c}{d}$ 的所有二元组 $(p, q)$ ...

  3. Anaconda3(1)Windows10下安装Anaconda3(64位)详细过程

    https://blog.csdn.net/ychgyyn/article/details/82119201 前言Anaconda指的是一个开源的Python发行版本,其包含了conda.Python ...

  4. Pandas | 08 重建索引

    重新索引会更改DataFrame的行标签和列标签. 可以通过索引来实现多个操作: 重新排序现有数据以匹配一组新的标签. 在没有标签数据的标签位置插入缺失值(NA)标记. import pandas a ...

  5. 踩iviewui中Tabs 标签页数据绑定坑

    今天小颖要实现点击Tabs 标签页中每个标签,并动态获取当前点击的标签值. 一句话说不清楚,那就看动态图吧 小颖一开始看官网写的代码是: <template> <Tabs :valu ...

  6. PATA1012The Best Rank(25分)

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...

  7. 每日一问:讲讲 Java 虚拟机的垃圾回收

    昨天我们用比较精简的文字讲了 Java 虚拟机结构,没看过的可以直接从这里查看: 每日一问:你了解 Java 虚拟机结构么? 今天我们必须来看看 Java 虚拟机的垃圾回收算法是怎样的.不过在开始之前 ...

  8. 远程windows

    1. 起因 因为经常用teamviewer,所以断定我是商业用户,不允许我用了.想买一个授权,结果太贵了,1700多.使用了很多其他的,向日葵卡顿,有的窗口点不到,vnc慢,效果差,卡顿,还收费,等等 ...

  9. 不让应用的日志输出到message文件中

    有时我们制定一个应用的日志输出到一个文件的时候例如: (百度了好久都百度不好,这里记录一下时间2015年12月7日16:28:39) local7.*                          ...

  10. ASP.NET-------gridview 进行编辑的时候,给出提示

    在使用gridview 控件的时候,控制修改人的操作行为,并给出合理的提示, 比如 在执行编辑操作的时候  不允许姓名为空,并显示出提示,姓名不可以为空 操作: 前台页面,对一些字段的解释 一定要注意 ...