diff --git a/src/api/global-api.md b/src/api/global-api.md index b5b7582fc6..d30851a246 100644 --- a/src/api/global-api.md +++ b/src/api/global-api.md @@ -451,3 +451,26 @@ const app = createApp({ ``` **See also**: [`$nextTick` instance method](instance-methods.html#nexttick) + +## mergeProps + +Takes multiple objects containing VNode props and merges them into a single object. A newly created object is returned, the objects passed as arguments are not modified. + +Any number of objects can be passed, with properties from later arguments taking precedence. Event listeners are handled specially, as are `class` and `style`, with the values of these properties being merged rather than overwritten. + +```js +import { h, mergeProps } from 'vue' + +export default { + inheritAttrs: false, + + render() { + const props = mergeProps({ + // The class will be merged with any class from $attrs + class: 'active' + }, this.$attrs) + + return h('div', props) + } +} +```