Mobx:有没有办法使用 mobx 实用程序查找表单是否脏

Mobx : Is there a way to find whether a form isDirty using a mobx Utility

有没有一种方法可以使用 mobx 实用程序查找表单是否脏

您可以使用 mobx-utils 中的 createViewModel:

class Todo {
  @observable title = "Test";
}

const model = new Todo();
const viewModel = createViewModel(model);

viewModel.title = "Get tea";
console.log(viewModel.isDirty); // true

对于完整的 MobX 表单解决方案,您可以查看 mobx-react-form,它支持在字段上检查 isDirty