Vue Component Preview
WARNING
Note that the version after 2.0.0-rc.5
cancels the ability of the vue-previews
folder, and all components can be declared in the folder components
.
TIP
By default, the theme registers the .vue
component under /.vuepress/components
globally, so the components that need to be previewed should be placed in this directory. Note:-``_
is not allowed in the file name.
If our project is stored in a subdirectory of the project, such as the /docs
folder, we need to set themeConfig.docsDir
to /docs
.
Input
@[preview](@/docs/.vuepress/components/demo.vue)
Output
My name is reco.
This is a vue preview demo.
<template>
<div class="demo-container">
<h3 style="widht">My name is {{name}}.</h3>
<p>This is a vue preview demo.</p>
</div>
</template>
<script setup lang="ts">
import { useInfo } from "./demo.ts";
const { name } = useInfo()
</script>
<style>
.demo-container {
width: 300px;
}
</style>
export function useInfo() {
const name = 'reco'
return { name }
}