karol-f / vue-custom-element

Vue Custom Element - Web Components' Custom Elements for Vue.js
https://karol-f.github.io/vue-custom-element/
MIT License
1.97k stars 187 forks source link

Use vue-custom-element with TypeScript and Router combination #262

Closed borishuseincehajic closed 2 years ago

borishuseincehajic commented 2 years ago

Hi,

So trying to wrap my head around this one.

I went through the existing closed issues and I was successfully using the options to init the custom element like this:

Vue.customElement('some-component',(someComponent as any).options); And this works great. Now I have introduced router to the component and I'm having issues with it.

If I try to attach the router like: someComponent.router = router; It doesn't work.

If I try to set it up like this: Vue.customElement('some-component', { router, render: h => h(someComponent) }); This works but the problem is that props are not being passed anymore from the component. So <some-component anyProp="test"></some-component> will not work anymore as anyProp is undefined now. But the router works in that case.

Any solution much appreciated.

karol-f commented 2 years ago

Maybe someComponent.options.router = router;?

borishuseincehajic commented 2 years ago

Thanks, @karol-f that works. Saved me some time. Thank you for your project by the way and keep up the good work.

karol-f commented 2 years ago

Good to hear that, take care!