!async function() {
const $btn = $('#calc');
$btn.off('click');
$btn.after("<p></p>")
try { //await
await new Promise(r =>
$btn.click(function() {
let
x = parseFloat($('#x').val()),
y = parseFloat($('#y').val()),
r;
if (isNaN(x) || isNaN(y)) {
try {
$(this).next().text('输入有误');
throw new Error('输入有误');
} catch (e) {
$(this).next().text('输你妹');
throw new Error('输你妹');
}
} else {
r = x + y;
$(this).next().text('计算结果:' + r);
})
.click(function() {
r();
}));
console.log("hi");
console.log(e)
$btn.next().text('输入有误!');
}();
Sign in to make a reply
Junes_99994
!async function() {
const $btn = $('#calc');
$btn.off('click');
$btn.after("<p></p>")
try { //await
await new Promise(r =>
$btn.click(function() {
let
x = parseFloat($('#x').val()),
y = parseFloat($('#y').val()),
r;
if (isNaN(x) || isNaN(y)) {
try {
$(this).next().text('输入有误');
throw new Error('输入有误');
} catch (e) {
$(this).next().text('输你妹');
throw new Error('输你妹');
}
} else {
r = x + y;
$(this).next().text('计算结果:' + r);
}
})
.click(function() {
r();
}));
console.log("hi");
} catch (e) {
console.log(e)
$btn.next().text('输入有误!');
}
}();