#Vue 3 - components inside components don't ork
40 messages · Page 1 of 1 (latest)
Yes, I thought so @amber mesa but my issue is that I can't use Vue components inside another Vue component.
Is this a bug in Astro, or do I need to only use Vue components inside .astro files? (And not in .vue components)
This is not an issue in normal Vue 3
Have you tried without the client:visible?
Yes, I tried that first
Do you get any error ?
No, no error, just that nothing happens
Hmm I don't see any reason why simply importing components would not work, would you create a minimal repro so I can take a look?
Hmm, I'll do some more testing just to make sure I haven't missed anything, if I still encounter issues, I'll make a repro.
Is codesandbox the best, or do you have a better suggestion for a repro?
Stackblitz has been more snappy in my experience
You can start from here if you don't find the issue https://stackblitz.com/github/withastro/astro/tree/latest/examples/framework-vue
Run official live example code for Astro Framework Vue, created by Withastro on StackBlitz
@amber mesa
I have narrowed it down to the following line:
`
<script setup>
const product = await getSingleProduct(props.id) // <- If I uncomment this, it works
</script>
`
This seems to work fine in an .astro page, but not inside a Vue component
It's a simple Graphql fetch function
I tried to but I couldn't reproduce, if you could create a reproduction it would be much easier to find if it's a bug or a usage issue
Nice I'll take a look!
Your problem seems to be:
[Vue warn]: Component <Anonymous>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.
at <MainButton >
at <App>
See the console of the component
BTW: You dont have a slot in the vue file but try to pass something into the component
It seems like you need to wrap your components inside of <Suspense> such that async setup functions are only used in child components.
See https://stackblitz.com/edit/github-xvbz3f-ckcrp2?file=src%2Fcomponents%2FMainButton.vue
I have a similar issue
I am using a main vue component in my astro app and I would like to break it down into smaller components by importing them into the main component. This doesn't seem to work. as it "can't be found". Is this possible? What is the Astro way to achieve this?
example:
# pages/about.astro
---
import MyVueComponent from '../components/MyVueComponent.vue';
---
<html>
<body>
<h1 class="editable">Use Vue components directly in Astro!</h1>
<MyVueComponent />
</body>
</html>
# components/MyVueComponent.vue
... Can't find SubComponent error
<script lang="ts">
import SubComponent from '../components/shared/SubComponent.vue'
export default {
components: {
SubComponent
}
}
</script>
Is this vue 2?
Asking because Astro doesn't support vue 2
Update here
It appears to not like that its inside a directory i.e components/test/test.vue in the components folder
But linking to other components directly within the components/ directory works
Organizing components seems important. Not sure if this is a known bug
(perhaps a bug with the astro/vue plugin?)
Should I direct this towards that team?
Probably. Not sure what's happening here
Is there a channel for that? Sorry I am new to the discord
Or you think I should open an issue on the repo?
Open a New Issue
https://github.com/withastro/astro/issues/new/choose
thank you
oh you know what. I think you were right about vue 2 and 3. You have to use the composition API for it to work