const engagementModel = types.model('engagementModel', { equity_type: types.maybeNull(types.string), show: types.maybeNull(types.boolean), head_image:types.maybeNull(types.string), nick_name: types.maybeNull(types.string), phone: types.maybeNull(types.string), service_list: types.array(types.string), imageArray: types.array(imageArrayModel), }); const imageArrayModel = types.model('imageArrayModel', { head_image:types.maybeNull(types.string), nick_name: types.maybeNull(types.string), }); const HealthyShotStore = types .model('HealthyShotStore', { picUrlsArray: types.array(picUrlModel), indexs: types.number, handCustomerArray: types.array(handCustomerModel), engagementArray: types.array(engagementModel), selectIndex: types.number, checkDetailList: types.array(types.string), handCustomerFlag: types.string, })的这个types.array(imageArrayModel)为什么报错
时间: 2024-03-13 09:43:06 浏览: 15
这个错误是因为在定义 `engagementModel` 中的 `imageArray` 属性时,使用了未定义的 `imageArrayModel` 类型,应该将 `imageArrayModel` 的定义放在 `engagementModel` 之前,或者使用 `types.late` 来延迟定义 `imageArrayModel` 的类型,例如:
```
const engagementModel = types.model('engagementModel', {
equity_type: types.maybeNull(types.string),
show: types.maybeNull(types.boolean),
head_image: types.maybeNull(types.string),
nick_name: types.maybeNull(types.string),
phone: types.maybeNull(types.string),
service_list: types.array(types.string),
imageArray: types.array(types.late(() => imageArrayModel)),
});
const imageArrayModel = types.model('imageArrayModel', {
head_image: types.maybeNull(types.string),
nick_name: types.maybeNull(types.string),
});
const HealthyShotStore = types.model('HealthyShotStore', {
picUrlsArray: types.array(picUrlModel),
indexs: types.number,
handCustomerArray: types.array(handCustomerModel),
engagementArray: types.array(engagementModel),
selectIndex: types.number,
checkDetailList: types.array(types.string),
handCustomerFlag: types.string,
});
```
这样就可以成功定义 `engagementModel` 中的 `imageArray` 属性了。