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

External variables #180

Closed enzonotario closed 4 years ago

enzonotario commented 4 years ago

Hi! Firstly, thanks so much for your amazing work!

I have a little doubt. I'm trying to make a widget, but that widget will use Apollo (at least for now, maybe later I can make just a little api to simplify). Moreover, that widget has to connect to different graphql endpoints, so it can connect to: example.com/graphql, anothereweb.com/graphql and so on.

I want to have just one build, so I need a way to pass from the parent the endpoint that the widget should use to connect. Moreover, it can't be done through props, because Apollo initilization occurs in main.js (not in a component).

How can I deal with this? Thanks in advance!

karol-f commented 4 years ago

Share variables using e.g. same Vuex instance or even global window.

You can also add some variable to component passed to Vue.customElement.

Feel free to ask more questions. Regards

enzonotario commented 4 years ago

Nice, the old window object works fine. Thanks so much!!!