We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当我将一个组件全局注册后,在 Markdown 使用该组件时,发现渲染的是: 渲染的是默认的值, 而不是 希望渲染的是来自于这里 Slot 定义的内容, 这不是我们想要的
渲染的是默认的值
希望渲染的是来自于这里 Slot 定义的内容
Bug 重现: https://stackblitz.com/edit/vite-7waswa?file=docs%2Fbug.md
当我将一个组件全局注册后,在 Markdown 使用该组件时,希望也能接受并渲染来自于父组件的 Slot 定义
System: OS: macOS 14.2.1 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 3.31 GB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node Yarn: 1.22.22 - /usr/local/bin/yarn npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm pnpm: 9.0.6 - /usr/local/bin/pnpm bun: 1.1.7 - /usr/local/bin/bun Browsers: Chrome: 124.0.6367.119 Safari: 17.2.1 npmPackages: vitepress: ^1.1.4 => 1.1.4
No response
The text was updated successfully, but these errors were encountered:
defineClientComponent currently doesn't forward slots. You can do something like this:
defineClientComponent
import { h, shallowRef, onMounted } from 'vue'; import { Theme } from 'vitepress'; import DefaultTheme from 'vitepress/theme'; import './style.css'; export default { extends: DefaultTheme, Layout: () => h(DefaultTheme.Layout), enhanceApp({ app }) { app.component('CustomComponent', { setup(props, { slots }) { const comp = shallowRef(); onMounted(async () => { let res = await import('../preset/CustomComponent.vue'); if (res && (res.__esModule || res[Symbol.toStringTag] === 'Module')) { res = res.default; } comp.value = res; }); return () => (comp.value ? h(comp.value, props, slots) : null); }, }); }, } satisfies Theme;
https://stackblitz.com/edit/vite-ajq8wc?file=docs/.vitepress/theme/index.ts
Sorry, something went wrong.
可以修复其问题,实现 Slots 功能。 但是感觉不是很优雅~
No branches or pull requests
Describe the bug
当我将一个组件全局注册后,在 Markdown 使用该组件时,发现渲染的是:
渲染的是默认的值
, 而不是希望渲染的是来自于这里 Slot 定义的内容
, 这不是我们想要的Reproduction
Bug 重现:
https://stackblitz.com/edit/vite-7waswa?file=docs%2Fbug.md
Expected behavior
当我将一个组件全局注册后,在 Markdown 使用该组件时,希望也能接受并渲染来自于父组件的 Slot 定义
System Info
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: