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"的位置?
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Flexslider 箭头未正确显示 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
