Mobx-state-tree:如何将 AnonymousModel 重命名为商店名称
Mobx-state-tree: how to rename AnonymousModel to the store name
我正在使用 mobx-state-tree,我想在出现错误时实际显示商店名称而不是 AnonymousModel。
例如:
const SignupModel = types
.model({
isUsingFacebook: false,
birthday: '',
timeOfBirth: types.maybeNull(types.string),
placeOfBirth: types.maybeNull(types.string),
gender: types.maybeNull(types.string),
password: '',
})
仍然给我一个类似
的错误
Error while converting {...} to AnonymousModel.
但我想得到
Error while converting {...} to SignupModel.
只需将所需名称作为第一个参数传递给 model
方法,如下所示:
const SignupModel = types
.model('SignupModel', {
isUsingFacebook: false,
birthday: '',
timeOfBirth: types.maybeNull(types.string),
placeOfBirth: types.maybeNull(types.string),
gender: types.maybeNull(types.string),
password: '',
})
我正在使用 mobx-state-tree,我想在出现错误时实际显示商店名称而不是 AnonymousModel。
例如:
const SignupModel = types
.model({
isUsingFacebook: false,
birthday: '',
timeOfBirth: types.maybeNull(types.string),
placeOfBirth: types.maybeNull(types.string),
gender: types.maybeNull(types.string),
password: '',
})
仍然给我一个类似
的错误Error while converting {...} to AnonymousModel.
但我想得到
Error while converting {...} to SignupModel.
只需将所需名称作为第一个参数传递给 model
方法,如下所示:
const SignupModel = types
.model('SignupModel', {
isUsingFacebook: false,
birthday: '',
timeOfBirth: types.maybeNull(types.string),
placeOfBirth: types.maybeNull(types.string),
gender: types.maybeNull(types.string),
password: '',
})