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. centos定时删除log文件

    #!bin/bash #获取年 time=$(date "+%Y") #查找并删除7天前的文件 find /opt/applog/travelsky -type f -mtime ...

  2. Scrapy笔记(1)- 入门篇

    Scrapy笔记01- 入门篇 Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架.可以应用在包括数据挖掘, 信息处理或存储历史数据等一系列的程序中.其最初是为了页面抓取(更确切来说, ...

  3. LRU Algorithm Gym - 102394L (HASH)

    LRU Algorithm \[ Time Limit: 1000 ms\quad Memory Limit: 524288 kB \] 题意 给出 \(n\) 个数字和 \(m\) 次查询. 每次询 ...

  4. python输出带颜色字体

    方法1: (参考https://suixinblog.cn/2019/01/print-colorful.html) 使用Python中自带的print输出带有颜色或者背景的字符串 书写语法 prin ...

  5. sass、less异同

    相同点: 1.混入(Mixins):class中的class 2.参数混入:可以传递参数的class,就像函数一样 3.嵌套规则:class中嵌套class,从而减少重复的代码 4.运算:css中用上 ...

  6. 请指出document load和document ready的区别

    document load文档的所有内容都加载完成 document ready文档的DOM加载完成

  7. selenium--页面元素相关的操作

    获取元素的标签和元素大小 from selenium import webdriver import unittest class Test_BasicInfo(unittest.TestCase): ...

  8. 【可持久化线段树】【P5826】【模板】子序列自动机

    [可持久化线段树][P5826][模板]子序列自动机 Description 给定一个序列 \(A\),有 \(q\) 次询问,每次询问一个序列 \(B\) 是不是 \(A\) 的子序列 Limita ...

  9. C++ getline()的两种用法

    getline():用于读入一整行的数据.在C++中,有两种getline函数.第一种定义在头文件<istream>中,是istream类的成员函数:第二种定义在头文件<string ...

  10. flume安装使用+根据数据源分类

    安装搭建: 1)解压下载的flume(安装jdk1.6及其以上) 2)在conf文件夹里面建立example.conf文件 #example.conf:单节点Flume配置 #命名Agent a1的组 ...