data: {
id: id ? id : '',
name: name,
subDesc: subDesc ? subDesc : '',
startDate: beginTime,
endDate: endTime,
questionCycle: '1',
numCopies: 6,
questionProblem: [
{
problemNo: problemNo,
type: type,
level: 2,
title: title,
isAnswer: isAnswer,
subDesc: subDesc2 ? subDesc2 : '',
questionOption: [
{
optionNo,
content,
subDesc: subDesc3 ? subDesc3 : '',
},
],
},
],
},
你是说这种:id: id ? id : ''吗?
这个不是覆盖,这个是设置默认值。当id的值是null的时候,就取''。
如果你发现实际值与你期望的不一致,检查一下赋值前,id是不是null
按常理不会覆盖的,你的描述有问题吧。不建议json里还用三目运算