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"的位置?
基础教程推荐
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
