我得到上面的错误与下面的示例代码,我很新的嵌套三元操作,所以你的帮助将不胜感激。示例代码如下:
Car4 = {
data: {
CoverBasis: item.coverBasis() || "Client",
IncludeInPackage: item.canBeIncludedInPackage() ?
(item.includeInPackage() && totalPolicies > 1 ? "Yes" : "No") : "No"
}
};
我认为错误告诉您移动分隔变量中的巢式三元运算符totalPolicies > 1 ? "Yes" : "No"
,如下所示:
const areTotalPoliciesBiggerOne = totalPolicies > 1 ? "Yes" : "No";
Car4 = {
data: {
CoverBasis: item.coverBasis() || "Client",
IncludeInPackage: item.canBeIncludedInPackage() ?
(item.includeInPackage() && areTotalPoliciesBiggerOne) : "No"
}
};