如何写精华回答,获更多曝光?
发布
ets文件,合并两个Record记录,报错It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (ArkTS-no-spread)
type MyRecord = Record<string, number>;
const record1: MyRecord = {
'a': 1,
'b': 2,
};
const record2: MyRecord = {
'b': 3, // 注意这里将覆盖record1中的'b'
'c': 4,
};
const mergedRecord: MyRecord = {
...record1,
...record2,
};