store.js 451 B

1234567891011121314151617181920
  1. //在这个js文件中,专门来创建Store的实例对象
  2. import {action, observable} from 'mobx-miniprogram'
  3. export const store = observable(
  4. {
  5. numA:1,
  6. numB:2,
  7. //计算属性
  8. get sum(){
  9. return this.numA + this.numB
  10. },
  11. //actions 方法,用来修改store中的数据
  12. updateNum1:action(function(step){
  13. this.numA += step;
  14. }),
  15. updataNum2:action(function(step){
  16. this.numB +=step;
  17. })
  18. }
  19. )