检查元素长度以标记状态布尔值
Check the element length to flag status boolean
我在这个 return 对象中默认分配 checked false
,请参阅代码
return Object.assign(file, {
temp_id: _.uniqueId(),
checked: false,
})
我有一个例外,如果它是我丢失的第一个文件我想要 checked: true
,
我知道我丢的第一个文件是在
const filePosition = files.length
returns 0
,
如何在我的 checked
中应用此条件?
如果我没理解错的话,如果 file.length === 0
和 false
和 file.length !== 0
,您想将 checked
更新为 true
如果这是正确的,你可以这样做:
return Object.assign(file, {
temp_id: _.uniqueId(),
checked: files.length === 0,
})
我在这个 return 对象中默认分配 checked false
,请参阅代码
return Object.assign(file, {
temp_id: _.uniqueId(),
checked: false,
})
我有一个例外,如果它是我丢失的第一个文件我想要 checked: true
,
我知道我丢的第一个文件是在
const filePosition = files.length
returns 0
,
如何在我的 checked
中应用此条件?
如果我没理解错的话,如果 file.length === 0
和 false
和 file.length !== 0
checked
更新为 true
如果这是正确的,你可以这样做:
return Object.assign(file, {
temp_id: _.uniqueId(),
checked: files.length === 0,
})