File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ These options will be merged with the component's existing options when mounted
1010:::
1111
1212- [ ` context ` ] ( #context )
13+ - [ ` data ` ] ( #data )
1314- [ ` slots ` ] ( #slots )
1415- [ ` scopedSlots ` ] ( #scopedslots )
1516- [ ` stubs ` ] ( #stubs )
@@ -44,6 +45,43 @@ const wrapper = mount(Component, {
4445expect (wrapper .is (Component)).toBe (true )
4546```
4647
48+ ## data
49+
50+ - type: ` Function `
51+
52+ Passes data to a component. It will merge with the existing ` data ` function.
53+
54+ Example:
55+
56+ ``` js
57+ const Component = {
58+ template: `
59+ <div>
60+ <span id="foo">{{ foo }}</span>
61+ <span id="bar">{{ bar }}</span>
62+ </div>
63+ ` ,
64+
65+ data () {
66+ return {
67+ foo: ' foo' ,
68+ bar: ' bar'
69+ }
70+ }
71+ }
72+
73+ const wrapper = mount (Component, {
74+ data () {
75+ return {
76+ bar: ' my-override'
77+ }
78+ }
79+ })
80+
81+ wrapper .find (' #foo' ).text () // 'foo'
82+ wrapper .find (' #bar' ).text () // 'my-override'
83+ ```
84+
4785## slots
4886
4987- type: ` { [name: string]: Array<Component>|Component|string } `
You can’t perform that action at this time.
0 commit comments