我试图通过使用for循环创建以下数组.但是,我的结果是一个长度为24且内部所有对象变成的数组{ key: '23', text: '12:30', value: '12:30' },而不是逐个迭代.任何人都可以向我解释为什么每次迭代都会覆盖前一次迭代?
const timeOptions = [
{ key: '0', text: '1:00', value: '1:00' },
{ key: '1', text: '1:30', value: '1:30' },
{ key: '2', text: '2:00', value: '2:00' },
{ key: '3', text: '2:30', value: '2:30' },
{ key: '4', text: '3:00', value: '3:00' },
{ key: '5', text: '3:30', value: '3:30' },
{ key: '6', text: '4:00', value: '4:00' },
{ key: '7', text: '4:30', value: '4:30' },
{ key: …Run Code Online (Sandbox Code Playgroud) 如果在三元运算符内满足条件,我试图渲染两个组件.但是,仅渲染第二个组件.我怎么可能在条件之后放两个函数调用?
{
views === "monthly"
? this.renderDays(),
this.renderCells()
: null
}
Run Code Online (Sandbox Code Playgroud)
我尝试了以下(没有一个工作)
{
views === "monthly"
? this.renderDays(),
this.renderCells()
: null
}
{
views === "monthly"
? (this.renderDays(), this.renderCells())
: null
}
{
views === "monthly"
? (this.renderDays(); this.renderCells())
: null
}
Run Code Online (Sandbox Code Playgroud)