gpt4 book ai didi

vue.js - vuepress - 如何使用注册组件自定义组件目录 '.vuepress/components' 的位置?

转载 作者:搜寻专家 更新时间:2023-10-30 22:14:59 28 4
gpt4 key购买 nike

我尝试使用插件 register/components 在 vuepress 中添加自定义组件目录,但似乎不可能。

我试过

module.exports = {
title: 'Hello VuePress',
description: 'Just playing around',
plugins: [
[
'register-components',
{
componentDir: '../components'
}
]
]
}

有了这个架构(我想选择“components”目录)

enter image description here

但是好像不行,因为组件没有被识别

enter image description here

我认为我在 base-button.md 中写的很好

enter image description here

有人可以帮我告诉我到达那里的步骤吗?

非常感谢

最佳答案

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

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)
}

关于vue.js - vuepress - 如何使用注册组件自定义组件目录 '.vuepress/components' 的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51987732/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com