Vue 组件预览

reco_luan2022-01-29

WARNING

注意,2.0.0-rc.5 之后的版本取消了 vue-previews 文件夹的能力,所有组件都可以放在文件夹 components 中声明。

TIP

主题默认将 /.vuepress/components 下面的 .vue 组件进行了全局注册,所以需要预览的组件请放在此目录下,注意:文件名不允许有 - _

如果我们文档项目存放在工程的子目录,比如 /docs 文件夹下,我们需要设置 themeConfig.sourceDir./docs

输入

@[preview](@/docs/.vuepress/components/demo.vue)

输出

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 }
}
最后更新时间 4/26/2024, 5:23:54 PM