最近開始用vue來開發項目,結果是一臉懵逼。。。對vuex他的運行機制不怎么理解,然后就去看了https://github.com/vuejs/vuex... 這個簡易教程結果運行起來各種報錯,完全不知道怎么改,比如:<template> <div> <button @click='increment'>Increment +1</button> </div></template><script>import { incrementCounter } from '../vuex/actions'export default { vuex: { actions: { increment: incrementCounter } }}</script>上面這個組件中綁定了increment方法,在運行的時候就會說increment沒有定義,按照一般的組件方法也應該是綁定在methods里面的,不知道那個教程里面這樣套在vuex下面的actions要怎樣才能被綁定上去;還有一個display組件<template> <div> <h3>Count is {{ counterValue }}</h3> </div></template><script>import { getCount } from '../vuex/getters'export default { vuex: { getters: { // 注意在這里你需要 `getCount` 函數本身而不是它的執行結果 'getCount()' counterValue: getCount } }}他也是直接的就放在vuex下面的一個屬性里面結果就是報錯,說counterValue is not defined看這個教程的時候最不能理解的就是這個vuex屬性,他是怎樣完成數據綁定的,我按照教程上寫結果一堆報錯,不知道是版本問題還是其他什么問題引起的,我用的vue和vuex都是2.0.0的
添加回答
舉報
0/150
提交
取消