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
10
10
:::
11
11
12
12
- [ ` context ` ] ( #context )
13
+ - [ ` data ` ] ( #data )
13
14
- [ ` slots ` ] ( #slots )
14
15
- [ ` scopedSlots ` ] ( #scopedslots )
15
16
- [ ` stubs ` ] ( #stubs )
@@ -44,6 +45,43 @@ const wrapper = mount(Component, {
44
45
expect (wrapper .is (Component)).toBe (true )
45
46
```
46
47
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
+
47
85
## slots
48
86
49
87
- type: ` { [name: string]: Array<Component>|Component|string } `
You can’t perform that action at this time.
0 commit comments