$w.onReady(function () {
// 当点击按钮时触发计算
$w('#btnCalculate').onClick(() => {
let price = Number($w('#inputPrice').value);
let down = Number($w('#inputDown').value);
let years = Number($w('#inputYears').value);
let rate = Number($w('#inputRate').value) / 100 / 12;
let loanAmount = price - down;
let months = years * 12;
if (loanAmount <= 0 || years <= 0 || rate <= 0) {
$w('#txtResult').text = "❌ 请检查输入";
return;
}
// 月供计算公式
let monthly = loanAmount * rate * Math.pow(1 + rate, months) / (Math.pow(1 + rate, months) - 1);
// 显示结果(两位小数)
$w('#txtResult').text = "每月还款: RM " + monthly.toFixed(2);
});
});
top of page
bottom of page
$w.onReady(function () {
// 当点击按钮时触发计算
$w('#btnCalculate').onClick(() => {
let price = Number($w('#inputPrice').value);
let down = Number($w('#inputDown').value);
let years = Number($w('#inputYears').value);
let rate = Number($w('#inputRate').value) / 100 / 12;
let loanAmount = price - down;
let months = years * 12;
if (loanAmount <= 0 || years <= 0 || rate <= 0) {
$w('#txtResult').text = "❌ 请检查输入";
return;
}
// 月供计算公式
let monthly = loanAmount * rate * Math.pow(1 + rate, months) / (Math.pow(1 + rate, months) - 1);
// 显示结果(两位小数)
$w('#txtResult').text = "每月还款: RM " + monthly.toFixed(2);
});
});
留言