> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/util/bindall.md).

# \_.bindAll

**语法：**

```javascript
_.bindAll(object, methodNames)
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L15280)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.bindall)

**描述：**

绑定一个对象的方法到对象本身，覆盖现有的方法。

> **注意:**&#x8FD9;个方法不会设置绑定函数的 "length" 属性。

**开始版本：**&#x30;.1.0

**参数：**

* `object (Object)`: 用来绑定和分配绑定方法的对象。
* `methodNames (...(string|string[]))`: 对象绑定方法的名称。

**返回值：**

* `(Object)`: 返回 object.

**例子：**

```javascript
var view = {
  'label': 'docs',
  'click': function() {
    console.log('clicked ' + this.label);
  }
};

_.bindAll(view, ['click']);
jQuery(element).on('click', view.click);
// => Logs 'clicked docs' when clicked.
```
