vuepress - How to custom location of components directory #39;.vuepress/components#39; with register-components?(vuepress - 如何使用 register-components 自定义组件目录“.vuepress/components的位置?)
问题描述
我尝试使用插件注册/组件在 vuepress 中添加自定义组件目录,但似乎不可能.
I tried to add custom directory of components in vuepress with plugin register/components but it seems not possible.
我试过了
module.exports = {
title: 'Hello VuePress',
description: 'Just playing around',
plugins: [
[
'register-components',
{
componentDir: '../components'
}
]
]
}
有了这个架构(我想选择组件"目录)
with this architecture (I want to select "components" directory)
但它似乎不起作用,因为组件无法识别
But it seem doesn't work because the component is not recognized
我认为我的组件在我的 base-button.md 中写得很好
I think that I wrote well my component in my base-button.md
有人可以帮我告诉我到达那里的步骤吗?
Is that someone could help me to tell me steps to get there?
非常感谢
推荐答案
可以在enhanceApp.js中全局注册组件(应该位于/.vuepress/ 文件夹),就像在 Vue 应用程序中注册它们一样.
You can register components globally in enhanceApp.js (which should be located in the /.vuepress/ folder) in the same way you register them in a Vue app.
enhanceApp.js
import BaseButton from '../../components/BaseButton'
export default ({
Vue, // the version of Vue being used in the VuePress app
options, // the options for the root Vue instance
router, // the router instance for the app
siteData // site metadata
}) => {
Vue.component('BaseButton', BaseButton)
}
这篇关于vuepress - 如何使用 register-components 自定义组件目录“.vuepress/components"的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:vuepress - 如何使用 register-components 自定义组件目录“.vuepress/components"的位置?
基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
