// 该文件用于创建store实例 import { action, observable } from 'mobx-miniprogram' export const store = observable({ // 数据字段 userInfo: {}, // 阅读结果 readDetail: {}, // 计算属性 get sum() { return this.numA + this.numB }, // actions setUser: action(function (step) { let grade = step.grade var gradeObj = { "PRIMARY_FIRST_GRADE": "一年级", "PRIMARY_SECOND_GRADE": "二年级", "PRIMARY_THREE_GRADE": "三年级", "PRIMARY_SENIOR_GRADE": "四年级", "PRESCHOOL": "学前班", } step.gradeName = grade ? gradeObj[grade] : '请选择' this.userInfo = step }, ), setReadDetail: action(function (detail) { console.log('store中的', detail); this.readDetail = detail }) })