---
title: Behavior
---

# Behavior(config: Object)

Register a `behavior` and receives an `Object` parameter.

## Parameter

| Property   | Type         | Required | Description                                                                                                                                                                                            | Minimum version |
| ---------- | ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------- |
| properties | Object Map   | No       | Same as the properties of the component.                                                                                                                                                               |                 |
| data       | Object       | No       | Same as the data of the component.                                                                                                                                                                     |                 |
| methods    | Object       | No       | Same as methods of a custom component.                                                                                                                                                                 |                 |
| behaviors  | String Array | No       | References another behavior.                                                                                                                                                                           |                 |
| lifetimes  | Object       | No       | The lifecycle declaration object, including `created`, `attached`, and `detached`. For more information, see [Component Lifecycles](/en/miniapp/develop/miniapp/framework/custom-component/lifetimes). |                 |
| created    | Function     | No       | The lifecycle function, declared in the `lifetimes` field.                                                                                                                                             |                 |
| attached   | Function     | No       | The lifecycle function, declared in the `lifetimes` field.                                                                                                                                             |                 |
| detached   | Function     | No       | The lifecycle function, declared in the `lifetimes` field.                                                                                                                                             |                 |

## Example

```js
// my-behavior.js
export default Behavior({
  behaviors: [],
  properties: {
    myBehaviorProperty: {
      type: String,
    },
  },
  data: {
    myBehaviorData: {},
  },
  lifetimes: {
    attached: function () {},
  },
  methods: {
    myBehaviorMethod: function () {},
  },
});
```
