我有一个枚举:
enum States {
Empty = 0,
NoData = 0x1,
UnChecked = 0x2,
Review = 0x4
}
我已将它们加载到多选控件中,因此可以将值选择到数组中,例如:[0, 0x1, 0x2]
如何获得打字稿中按位组合的值(示例中为6)?
您在问如何进行按位组合吗?
const addition = [
0x01,
0x02,
0x04,
].reduce((tmp, x) => tmp | x, 0);
console.log(`0x${addition.toString(16)}`);