@cocos3/mobx4
TypeScript icon, indicating that this package has built-in type declarations

4.0.4 • Public • Published

@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;
  }
}

Package Sidebar

Install

npm i @cocos3/mobx4

Weekly Downloads

0

Version

4.0.4

License

MIT

Unpacked Size

213 kB

Total Files

51

Last publish

Collaborators

  • ouyangbin