vuejs / vue-router

🚦 The official router for Vue 2
http://v3.router.vuejs.org/
MIT License
18.99k stars 5.06k forks source link

Vue 2.7 useRouter & Storybook #3844

Closed marciado closed 1 year ago

marciado commented 1 year ago

Version

3.6.5

Reproduction link

codesandbox.io

Steps to reproduce

I am not sure if this is a bug in vue-router or in storybook. So I kindly would like to ask if this is a bug. I use vue 2.7 and completely composition api with vue-router/composable. When I use the composable useRouter() inside the component it works fine. But when I create a story for the component, storybook crashes and says TypeError: root.$router is undefined. Is there something I missed to configure or is this a bug?

What is expected?

const router = useRouter();

should normally work in story and component

What is actually happening?

const router = useRouter();

works in component, crashes story


It would be very nice if you can help me with that or if I need to configure something :)

posva commented 1 year ago

This seems like a problem with Storybook and not vue router itself.