react-native - 领域:“数组”类型的属性“虚拟”不能为空
问题描述
我正在尝试使用这些模式打开一个领域连接。
[{
name: 'Day',
properties: {
day: {type: 'int', optional: true},
time: {type: 'string', optional: true},
}
},
{
name: 'Period',
properties: {
close: {type: 'Day', optional: true},
open: {type: 'Day', optional: true}
}
},
{
name: 'Dummy',
properties: {
isDummy: {type: 'bool', optional: true},
periods: {type: 'Period[]', optional: true},
}
}]
我得到这个错误:Property "Dummy" of type 'array' cannot be nullable
。
我不知道为什么会收到此错误。如果有人可以向我解释这一点,我将不胜感激。
解决方案
您应该像这样 [] 将默认值设置为空列表,因为您想要空数组。所以你应该使用这个:
{
name: 'Period',
properties: {
close: {type: 'Day[]', default: []}, // <-- change here
.....
}
}
代替:
{
name: 'Period',
properties: {
close: {type: 'Day', optional: true},
open: {type: 'Day', optional: true}
}
}
推荐阅读
- pandas - 将具有一个键和多个值的字典转换为数据框
- .net-core - 操作 Windows 10 音频音量设置 .NET Core
- android - Android 访问令牌上的 Google 日历 API
- c# - Html 找不到脚本
- formatter - 添加 bottomCalcFormatter 停止制表器生成
- qt - Qt-C++ 应用程序中的 PyQt 小部件
- python - SQlite - 为什么我需要提交命令
- python - 如何为 8-Queen 问题的 PMX 函数创建一个只有唯一值的数组?
- qt - Docker 文件中的 Qt 非交互式安装失败并出现 QXcbConnection DISPLAY 错误
- c - 为什么使用输入字符串在屏幕上打印垃圾值?