负载中的对象名称 javascript
name of object within payload javascript
我有这个负载。
{name: "Sinto 6", val: {…}, line: "Sinto 6"}
line: "Sinto 6"
name: "Sinto 6"
val:
AvgMachTime: 253
AvgManTime: 1343
CollectMachTimer: 359
CollectManTimer: 108
CycleTimeMach: 359
CycleTimeMan: 140
FaultTime: 15297
MachTargetSeconds: 330
ManTargetSeconds: 95
NGPartCount: 63
OnHeatTime: 11201
PartCount: 12
PartTarget: 78
我正在尝试使用 Vue 设置状态中的值使用
const PERFORMANCE_COMMIT = (state, payload) => {
Vue.set(state["Performance"][payload.line], [payload.val], payload.val);
}
我意识到我的 payload.val 之一需要是值的名称而不是名称本身。
如何正确引用它?
我的状态是这样的:
Performance: {
TotalPartTarget: 0,
TotalPartCount: 0,
Difference: 0,
OEE: 0,
OEETarget: 100,
"Sinto 6" :{
PartTarget: 0,
PartCount: 0,
NGPartCount: 0,
OEE: 0,
FaultTime: 0,
OnHeatTime: 0,
CycleTimeMan: 0,
CycleTimeMach: 0,
CollectManTimer: 0,
CollectMachTimer: 0,
AvgManTime: 0,
AvgMachTime: 0,
ManTargetSeconds: 0,
MachTargetSeconds: 0
编辑:拼写
根据 Vue 文档 (Vue.set Documentation Link),第一个参数是目标,第二个是 属性 名称/索引,第三个是值。
所以,在你的情况下,目标 属性 是 state["Performance"],属性 name 是 payload.line ("Sinto 6") 并且值为 payload.val.
const PERFORMANCE_COMMIT = (state, payload) => {
Vue.set(state["Performance"], payload.line, payload.val);
}
我有这个负载。
{name: "Sinto 6", val: {…}, line: "Sinto 6"}
line: "Sinto 6"
name: "Sinto 6"
val:
AvgMachTime: 253
AvgManTime: 1343
CollectMachTimer: 359
CollectManTimer: 108
CycleTimeMach: 359
CycleTimeMan: 140
FaultTime: 15297
MachTargetSeconds: 330
ManTargetSeconds: 95
NGPartCount: 63
OnHeatTime: 11201
PartCount: 12
PartTarget: 78
我正在尝试使用 Vue 设置状态中的值使用
const PERFORMANCE_COMMIT = (state, payload) => {
Vue.set(state["Performance"][payload.line], [payload.val], payload.val);
}
我意识到我的 payload.val 之一需要是值的名称而不是名称本身。
如何正确引用它?
我的状态是这样的:
Performance: {
TotalPartTarget: 0,
TotalPartCount: 0,
Difference: 0,
OEE: 0,
OEETarget: 100,
"Sinto 6" :{
PartTarget: 0,
PartCount: 0,
NGPartCount: 0,
OEE: 0,
FaultTime: 0,
OnHeatTime: 0,
CycleTimeMan: 0,
CycleTimeMach: 0,
CollectManTimer: 0,
CollectMachTimer: 0,
AvgManTime: 0,
AvgMachTime: 0,
ManTargetSeconds: 0,
MachTargetSeconds: 0
编辑:拼写
根据 Vue 文档 (Vue.set Documentation Link),第一个参数是目标,第二个是 属性 名称/索引,第三个是值。
所以,在你的情况下,目标 属性 是 state["Performance"],属性 name 是 payload.line ("Sinto 6") 并且值为 payload.val.
const PERFORMANCE_COMMIT = (state, payload) => {
Vue.set(state["Performance"], payload.line, payload.val);
}