Skip to content

vuex 2.0.rc.4 not work with standalone build vue/dist/vue.js(but work well with vue.common.js version) #280

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

Closed
cnweibo opened this issue Aug 15, 2016 · 8 comments

Comments

@cnweibo
Copy link

cnweibo commented Aug 15, 2016

Hi, i have tested the counter example in this repo's next branch.
I found one bug : if I try to write root vue init code without a render option, vue always complain:

Trying to access non-existent property "$store" while rendering. Make sure to declare reactive data properties in the data option. (found in component <counter>

The code is here for app.js:

import 'babel-polyfill'
import Vue from 'vue/dist/vue'          // here I must import this way, otherwise, error with "Failed to mount component: template or render function not defined." will be there
import Counter from './counter.vue'
import store from './store.js'
new Vue({
  el: '#app',
  store,
    components: {
        Counter
    } // here i'd like to init root vue instance in older way
  //render: h => h(Counter)
})

the code here is index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>vuex counter example</title>
  </head>
  <body>
    <div id="app">
        <p>this is app p tag content</p>
        <counter></counter>   
<!--  here i add the counter component manually in html page -->
    </div>
  </body>
</html>

Please fix it or give me workaround solution for it!
Thanks!

@fnlctrl
Copy link
Member

fnlctrl commented Aug 15, 2016

What's in your store.js? Are you importing the same vue?

@cnweibo
Copy link
Author

cnweibo commented Aug 15, 2016

@fnlctrl , thanks for your reply. I have import the same version vue: "standalone build vuejs version" via

import Vue from 'vue/dist/vue'
import Vuex from 'vuex'
...
other code is the vuex official counter example code

@cnweibo cnweibo changed the title vuex 2.0.rc.4 not work with vue/dist/vue.js(but work well with vue.common.js version) vuex 2.0.rc.4 not work with standalone build vue/dist/vue.js(but work well with vue.common.js version) Aug 15, 2016
@fnlctrl
Copy link
Member

fnlctrl commented Aug 15, 2016

Did you use Vue.use(Vuex) in store.js?

@fnlctrl
Copy link
Member

fnlctrl commented Aug 15, 2016

I am currently using standalone version of vue and vuex, and encountered no problems..

@fnlctrl
Copy link
Member

fnlctrl commented Aug 15, 2016

Trying to access non-existent property "$store" while rendering.
Are you using $store directly in your template?

@ktsn
Copy link
Member

ktsn commented Aug 15, 2016

This may be same problem of #264.
Please try #264 (comment)

@fnlctrl
Copy link
Member

fnlctrl commented Aug 15, 2016

Oh I see.. I'm not using vue-loader currently.
I guess @ktsn 's solution will work.

@cnweibo
Copy link
Author

cnweibo commented Aug 15, 2016

@ktsn
@fnlctrl
thanks for your hint, the solution mentioned by @ktsn really works for me. It is the issue of webpack vue-loader , not vuejs/vuex itself!

@cnweibo cnweibo closed this as completed Aug 15, 2016
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

3 participants