作者:是非涩味_943 | 来源:互联网 | 2022-12-09 20:04
我使用以下方法创建了从当年到1930年的降序整数数组moment
:
optiOns= Array(moment().year() - 1929).fill().map((_, index) => moment().year() - index)
我正在尝试转换options
为一个对象数组,以便生成的数组是这样的:
[{value: '2018', label: '2018'}, {value: '2017', label: '2017'}, ..., {value: '2', label: '2'}, {value: '1', label: '1'}]
CertainPerfo..
5
只是.map
对象的每个项目而不是单个数字:
const optiOns= Array(moment().year() - 1929)
.fill()
.map((_, index) => {
const value = moment().year() - index;
return { value, label: value };
});
console.log(options);
1> CertainPerfo..:
只是.map
对象的每个项目而不是单个数字:
const optiOns= Array(moment().year() - 1929)
.fill()
.map((_, index) => {
const value = moment().year() - index;
return { value, label: value };
});
console.log(options);