4.0.4 • Published 12 months ago

@cocos3/mobx4 v4.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

@cocos3/mobx4 包

将 mobx 打成 esm 包使用

import { action, observable, observer, render } from '@cocos3/mobx4';
import { _decorator, Component, Input, Label } from 'cc';
const { ccclass, property } = _decorator;

@observer
@ccclass('NewComponent')
export class NewComponent extends Component {
  @property(Label)
  private label: Label = null!;
  @observable
  private index = 0;
  protected onLoad(): void {
    this.node.on(Input.EventType.MOUSE_DOWN, this.onClick, this);
  }

  @action
  protected onClick() {
    this.index += 1;
  }

  @render
  protected render() {
    this.label.string = '点击次数: ' + this.index;
  }
}
4.0.4

12 months ago

4.0.3

12 months ago

4.0.1

12 months ago

4.0.0

12 months ago