Skip to content

Commit 1888864

Browse files
authored
Merge pull request #1376 from hiendv/docs-api-options-slots
docs: add an example for slots components with props
2 parents af37800 + be3ee28 commit 1888864

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Diff for: docs/api/options.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,43 @@ Example:
5454

5555
```js
5656
import Foo from './Foo.vue'
57+
import MyComponent from './MyComponent.vue'
5758

5859
const bazComponent = {
5960
name: 'baz-component',
6061
template: '<p>baz</p>'
6162
}
6263

64+
const yourComponent = {
65+
props: {
66+
foo: {
67+
type: String,
68+
required: true
69+
}
70+
},
71+
render(h) {
72+
return h('p', this.foo)
73+
}
74+
}
75+
6376
const wrapper = shallowMount(Component, {
6477
slots: {
6578
default: [Foo, '<my-component />', 'text'],
6679
fooBar: Foo, // Will match `<slot name="FooBar" />`.
6780
foo: '<div />',
6881
bar: 'bar',
6982
baz: bazComponent,
70-
qux: '<my-component />'
83+
qux: '<my-component />',
84+
quux: '<your-component foo="lorem"/><your-component :foo="yourProperty"/>'
85+
},
86+
stubs: {
87+
// used to register custom components
88+
'my-component': MyComponent,
89+
'your-component': yourComponent
90+
},
91+
mocks: {
92+
// used to add properties to the rendering context
93+
yourProperty: 'ipsum'
7194
}
7295
})
7396

0 commit comments

Comments
 (0)