diff --git a/docs/api/options.md b/docs/api/options.md index d385d3047..34f162755 100644 --- a/docs/api/options.md +++ b/docs/api/options.md @@ -10,6 +10,7 @@ These options will be merged with the component's existing options when mounted ::: - [`context`](#context) +- [`data`](#data) - [`slots`](#slots) - [`scopedSlots`](#scopedslots) - [`stubs`](#stubs) @@ -44,6 +45,43 @@ const wrapper = mount(Component, { expect(wrapper.is(Component)).toBe(true) ``` +## data + +- type: `Function` + +Passes data to a component. It will merge with the existing `data` function. + +Example: + +```js +const Component = { + template: ` +
+ {{ foo }} + {{ bar }} +
+ `, + + data() { + return { + foo: 'foo', + bar: 'bar' + } + } +} + +const wrapper = mount(Component, { + data() { + return { + bar: 'my-override' + } + } +}) + +wrapper.find('#foo').text() // 'foo' +wrapper.find('#bar').text() // 'my-override' +``` + ## slots - type: `{ [name: string]: Array|Component|string }`