由於我是angular轉的vue,第一次使用vuex的時候,照着文檔寫,打印this.$store 顯示的是一直是 undefined 百思不得琪姐。。先把代碼貼出來:vue
百度了不少,遇到這種問題的人,都是各類奇葩的緣由,最後轉一個博客裏面,仔細看了別人的寫法;原來轉store.js裏面,得這樣寫:node
個人vue版本:webpack
System:
OS: macOS 10.14.3
CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 73.0.3683.86
Firefox: Not Found
Safari: 12.0.3
npmPackages:
@vue/babel-helper-vue-jsx-merge-props: 1.0.0-beta.3
@vue/babel-plugin-transform-vue-jsx: 1.0.0-beta.3
@vue/babel-preset-app: 3.5.1
@vue/babel-preset-jsx: 1.0.0-beta.3
@vue/babel-sugar-functional-vue: 1.0.0-beta.3
@vue/babel-sugar-inject-h: 1.0.0-beta.3
@vue/babel-sugar-v-model: 1.0.0-beta.3
@vue/babel-sugar-v-on: 1.0.0-beta.3
@vue/cli-overlay: 3.5.1
@vue/cli-plugin-babel: ^3.5.0 => 3.5.1
@vue/cli-plugin-eslint: ^3.5.0 => 3.5.1
@vue/cli-service: ^3.5.0 => 3.5.1
@vue/cli-shared-utils: 3.5.1
@vue/component-compiler-utils: 2.6.0
@vue/preload-webpack-plugin: 1.1.0
@vue/web-component-wrapper: 1.2.0
eslint-plugin-vue: ^5.0.0 => 5.2.2
vue: ^2.6.6 => 2.6.10
vue-eslint-parser: 5.0.0
vue-hot-reload-api: 2.3.3
vue-loader: 15.7.0
vue-style-loader: 4.1.2
vue-template-compiler: ^2.5.21 => 2.6.10
vue-template-es2015-compiler: 1.9.1
vuex: ^3.1.0 => 3.1.0
npmGlobalPackages:
@vue/cli: Not Foundweb