添加一个生成随机数函数

This commit is contained in:
itgaojian163 2025-07-24 14:22:09 +08:00
parent 5d0841525a
commit f271f85e41

View File

@ -80,5 +80,11 @@ Page({
wx.navigateTo({
url: '/pages/login/login',
})
},
//生成随机数,保留小数点2位
random1To10(decimalPlaces = 2) {
const random = Math.random() * 9;
const result = random + 1;
return Number(result.toFixed(decimalPlaces));
}
})