# Vuex
**Repository Path**: Gnius/vuex
## Basic Information
- **Project Name**: Vuex
- **Description**: 2020年9月17日 凉爽 正在收玉米的时间 在家vuex
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-09-17
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## 学习 vuex 笔记
遇到的问题 1:使用严格模式 eslint 时,报错 Missing space before function parentheses 的问题
解决方法:打开.eslint 文件,并在 rules 中添加如下一行代码即可:
```
"space-before-function-paren": 0
```
遇到的问题 2:处理格式化代码的问题 在项目根目录下新建 .prettierrc.json 文件。去除分号,用单引号替换了双引号
```
{
"singleQuote": true,
"semi": false
}
```
**组件访问 State 中数据的第一种方式**
this.\$store.state.全局数据名
`
**组件访问 State 中数据的第二种方式**
组件中引入 mapState 函数 在 computed 中 ...mapState(['数据名'])
## Mutation 用于变更 Store 中的数据,必须是同步函数
定义和使用:

### 在 action 中,不能直接修改 state 中的数据

### 必须通过 context.commit(mutation 中的方法名)触发

