首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >vuepress -如何自定义组件目录'.vuepress/ components‘与寄存器-组件的位置?

vuepress -如何自定义组件目录'.vuepress/ components‘与寄存器-组件的位置?
EN

Stack Overflow用户
提问于 2018-08-23 14:05:00
回答 1查看 1.6K关注 0票数 4

我尝试用插件寄存器/组件在vuepress中添加组件的自定义目录,但这似乎是不可能的。

我试过

代码语言:javascript
复制
module.exports = {
  title: 'Hello VuePress',
  description: 'Just playing around',
  plugins: [
   [
     'register-components',
     {
       componentDir: '../components'
     }
   ]
  ]
}

使用此体系结构(我希望选择"components“目录)

但是它似乎不起作用,因为组件没有被识别

我想我把我的组件写得很好-按钮. my

有人能帮我告诉我去那里的步骤吗?

非常感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-27 03:14:27

您可以在enhanceApp.js中全局注册组件(应该位于/.vuepress/文件夹中),就像在Vue应用程序中注册组件一样。

enhanceApp.js

代码语言:javascript
复制
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)
}
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51987732

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档