I'm trying to set properties of a Javascript object (I'm speculating that it's not a plain JS Object but an instance of some kind of class, but I can't find what the class is)
我正在尝试设置Javascript对象的属性(我推测它不是一个简单的JS对象,而是某种类的实例,但我找不到该类的内容)
This is what the object looks like when I log it.
这是我记录对象时的样子。
result.data.info = {};
console.log(result.data);
result.data.info.UUID = uuid;
result.data.info.totalStressValue = totalValue;
console.log(result.data);
This blows up because result.data.info is undefined. I'm pretty sure it's a Jquery object, how can I set these properties? Thanks.
这会爆炸,因为result.data.info未定义。我很确定它是一个Jquery对象,我该如何设置这些属性?谢谢。
1 个解决方案
#1
0
you can initialize the whole object like this:
你可以像这样初始化整个对象:
result = {
data: {
info: {
UUID: uuid,
totalStressValue: totalValue
}
}
}
#1
0
you can initialize the whole object like this:
你可以像这样初始化整个对象:
result = {
data: {
info: {
UUID: uuid,
totalStressValue: totalValue
}
}
}