添加一个生成随机数函数
This commit is contained in:
parent
5d0841525a
commit
f271f85e41
@ -80,5 +80,11 @@ Page({
|
|||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/login/login',
|
url: '/pages/login/login',
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
//生成随机数,保留小数点2位
|
||||||
|
random1To10(decimalPlaces = 2) {
|
||||||
|
const random = Math.random() * 9;
|
||||||
|
const result = random + 1;
|
||||||
|
return Number(result.toFixed(decimalPlaces));
|
||||||
}
|
}
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user