if(numbers!='')
{
let parts = numbers.split(' ');
let isFirstNumber = true; // 标记是否是第一个数字
for (let i = 0; i < parts.length; i++) {
let part = parts[i];
if (!isNaN(part)) {
let number = parseInt(part, 10);
// 每隔一定时间显示数字和运算符
setTimeout(() => {
displayQuestion(number,'','');
}, (i + 1) * shijian * 1000);
if (isFirstNumber) {
isFirstNumber = false;
result += number; // 处理第一个数字
question += number;
} else {
if (lastOperator === '+') {
result += number;
} else if (lastOperator === '-') {
result -= number;
}
question += ' ' + lastOperator + number;
}
} else {
lastOperator = part; // 更新运算符
}
}
运算结果对了,但是后面的+号还是没显示出来