参考答案:
1 // 方法1: 2let arr1: (number | string)[] = [1] 3arr1.push(1) 4arr1.push('3') 5 6// 方法2: 7let arr2 : Array<string | number> = [1, '2'] 8arr2.push(1) 9arr2.push('3') 10 11// 方法3: 12type newType = number|string 13let arr3:newType []= [3] 14arr3.push(1) 15arr4.push('5')
最近更新时间:2023-03-12