返回 slidev
component.md
根目录 / docs / guide / component.md
1 # Components in Slides
2
3 One of the most powerful features of Slidev is the ability to use Vue components directly in your slides. This allows you to create interactive and dynamic content with ease.
4
5 ## Using Components {#use}
6
7 With the help of [`unplugin-vue-components`](https://github.com/unplugin/unplugin-vue-components), Slidev allows you to use Vue components directly in your slides without importing them manually:
8
9 ```md
10 # My Slide
11
12 <MyComponent :count="4"/>
13 ```
14
15 The components come from:
16
17 - Built-in components. See [Built-in Components](../builtin/components) for reference.
18 - Provided by the theme and addons. See <LinkInline link="guide/theme-addon" />.
19 - Custom components in the `components` directory. See the next section.
20
21 ## Writing Components {#write}
22
23 To create a custom component, simply create a new Vue file in the `components` directory:
24
25 ```bash
26 your-slidev/
27 ├── ...
28 ├── slides.md
29 └── components/
30 ├── ...
31 └── MyComponent.vue
32 ```
33
34 Refer to the [Vue documentation](https://vuejs.org/guide/essentials/component-basics.html) for how to write Vue components.
35
36 You can also <LinkInline link="guide/write-addon" /> to reuse and share your components with others.
37
37 lines MARKDOWN