![](/img/trans.png)
[英]How to assign the value of one attribute of one array of object to the similarly named attribute of another array of object? - Javascript
[英]One of attribute lost data when assign javascript object
我花了一天时间调查这个案子,但没有看到任何希望。
const Tests = (state = INIT_STATE, action) => {
switch (action.type) {
case GET_TEST_DETAIL:
return {
...state,
test: {},
error: {},
updatingTest: true,
}
case GET_TEST_DETAIL_SUCCESS:
const test = action.payload
console.log(action.payload.shortName)//has data
test["shortName2"] = action.payload.shortName//has data
test["shortName"] = action.payload.shortName//empty string
console.log(test)
return {
...state,
test: test,
updatingTest: false,
}
有我在 firefox 和 Edge console.log 时捕获的图片:
没有错。
const action = { payload: { shortName: 'I am a shortname' } } const test = action.payload console.log(action.payload.shortName)//has data test["shortName2"] = action.payload.shortName//has data test["shortName"] = action.payload.shortName//empty string console.log(test)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.