# Behavior(Object object)
Register abehaviorand take an argument of typeObject.
# parameter
# Object object
| Definition paragraph | type | Is it compulsory? | describe | Minimum version |
|---|---|---|---|---|
| properties | Object Map | no | The external properties of a component are a mapping table from the property name to the property settings. | |
| data | Object | no | Component internal data, along withpropertiesfor template rendering of components | |
| observers | Object | no | A component data field monitor that listens for changes in properties and data. See Data Monitor | 2.6.1 |
| methods | Object | no | Component methods, including event-response functions and any custom methods. For the use of event-response functions, see Intercomponent communication and events | |
| behaviors | String Array | no | Intercomponent code reuse mechanisms similar to mixins and traits, see behaviors | |
| created | Function | no | Component life periodic function - Executed when a component instance is created, note that you cannot callsetData) | |
| attached | Function | no | Component life periodic function - executed when a component instance enters the page node tree | |
| ready | Function | no | Component life periodic function - executed after the component layout is completed | |
| moved | Function | no | Component life periodic function - executed when the component instance is moved to another location in the node tree | |
| detached | Function | no | Component life periodic function - executed when a component instance is removed from the page node tree | |
| relations | Object | no | Inter-component relationship definition, see Inter-component relationship | |
| lifetimes | Object | no | Component lifecycle declaration object, see Component lifecycle | 2.2.3 |
| pageLifetimes | Object | no | Lifecycle declaration object for the page where the component resides, see Component Lifecycle | 2.2.3 |
| definitionFilter | Function | no | Define segment filters for custom component extensions, see Custom component extensions | 2.2.3 |
# sample code
// my-behavior.js
module.exports = Behavior({
behaviors: [],
properties: {
myBehaviorProperty: {
type: String
}
},
data: {
myBehaviorData: {}
},
attached: function(){},
methods: {
myBehaviorMethod: function(){}
}
})