我想在数组中的特定索引处推送布尔值。每当我运行代码时,我都会收到此错误, ERROR TypeError:无法读取属性' push'未定义的
这是我的代码:
{
auto state = std::make_unique<ThreadState>(ThreadState::Running);
vec.emplace_back(
std::async([s = state.get()] ()
{
*s = ThreadState::Waiting;
}),
std::move(state)
);
}
可能是什么问题?是否有另一种方法可以使用数组来实现相同的输出?
答案 0 :(得分:0)
您不需要将值file_get_contents('php://input')
推送到true
,您可以设置它:check_ins[i]
或将true推送到数组:check_ins[i] = true
< / p>
答案 1 :(得分:0)
使用push时,推送的值将作为新元素添加到数组中。我建议你改为:
var check_ins = [];
for (var i = 0; i < this.employees.length; i++) {
// let check = check_ins[i];
if (check_ins[i] === true) {
let alert = this.alertCtrl.create({
title: 'Sorry,',
subTitle: 'ur already checked in',
buttons: ['OK']
});
alert.present();
break;
} else if (check_ins[i] === false || check_ins[i] === undefined) {
let checkInTime = new TimeInModel(in_timing.date, emp_id, in_timing.time_in, true);
this.employeesService.pushTimeIn(checkInTime)
.subscribe(checkInTime => {
},
error => this.errorMessage = <any>error);
console.log("Successfully checked-in!");
check_ins[i]=true;
break;
}