Skip to content
New issue

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

[vuex] already installed. Vue.use(Vuex) should be called only once. #729

Closed
yepesasecas opened this issue Apr 5, 2017 · 2 comments
Closed

Comments

@yepesasecas
Copy link

Version

2.0.0

Reproduction link

https://jsfiddle.net/15ww4vog/7/

Steps to reproduce

  1. load jsfiddle page
  2. Vue init method is executed.
  3. vue init method makes a Ajax call to "https://api.myjson.com/bins/orphn". and responds a HTML, JS injected to #dinamic-container div.
  4. HTML, JS injected also includes a Vue instance.
  5. creating conflicts "[vuex] already installed. Vue.use(Vuex) should be called only once."

What is expected?

  1. load page, instantiate VUE.
  2. when a page is injected and includes a VUE instance. load with no conflicts.

What is actually happening?

  1. load page, instantiate VUE.
  2. when page is injected and includes a VUE instance. a conflict is raised and show the "[vuex] already installed. Vue.use(Vuex) should be called only once." console error.

Remember.

My parent view is loading Vue instance.
and I'm injecting a Child view that also contains its own Vue instance.

@ktsn
Copy link
Member

ktsn commented Apr 5, 2017

As the error message described, it's because you are installing Vuex into Vue two times - the first is in the script loaded at the same time as the page is loaded, the second is in late injected script after ajax request. Note that Vuex is automatically installed if Vue is in window.

FYI: you seems to load the library code in multiple times. It would cause unexpected behavior and should be avoided. I'm not sure why you load the script by explicitly calling ajax request but I would suggest you to load the libs only one time per page.

@ktsn ktsn closed this as completed Apr 5, 2017
@yepesasecas
Copy link
Author

@ktsn thank you.
In this case, I don't have to much control. we developed a checkout that can be injected in any merchants page, using the example I show you.

We ask the merchant to call our endpoint and include the html, js to their page.

I have control over the Vue instance that is called through Ajax.

There is a way I can create a scope/namespace? so both Vue instances can live in the same page?? or how can I prevent my instance to instantiate again and use the one already created.

thank you again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants