【问题标题】:In Vuepress is there a terse way to include components?在 Vuepress 中是否有一种简洁的方式来包含组件?
【发布时间】:2019-01-27 10:41:33
【问题描述】:

在 Vuepress 中,我可以将组件包含到 Markdown 中:

<template>
    <div class="thingy">
        <Thingy/>
    </div>
</template>

<script>
import Thingy from '../../components/Thingy'
export default {
  components: {Thingy},
}
</script>

但是它很啰嗦。有没有办法更简洁地做到这一点?

我怀疑目前还没有,我想知道我是否可以提出一些建议并提交一个拉取请求,但老实说我不知道​​如何实现它所以任何想法也将不胜感激收到

【问题讨论】:

    标签: vuepress


    【解决方案1】:

    如果你将组件放在/.vuepress/components/ 中,Vuepress 会为你注册组件,你可以直接在 markdown 中使用它。标签名和.vue文件一样,所以MyComponent.vue作为

    <MyComponent></MyComponent> 
    

    如果您想将组件定位到其他位置,请使用 enhanceApp.js,如此处所示 vuepress - How to custom location of components directory...

    【讨论】:

      猜你喜欢
      • 2011-11-05
      • 1970-01-01
      • 2010-09-05
      • 2017-03-27
      • 1970-01-01
      • 2019-08-24
      • 1970-01-01
      • 2012-12-10
      相关资源
      最近更新 更多