add randomExtend fun

This commit is contained in:
jiaming 2018-12-09 19:49:04 +08:00
parent 002e0de26d
commit a69781093d
1 changed files with 9 additions and 0 deletions

View File

@ -22,6 +22,14 @@ export function debounce (delay, callback) {
} }
} }
export function randomExtend (minNum, maxNum) {
if (arguments.length === 1) {
return parseInt(Math.random() * minNum + 1, 10)
} else {
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
}
}
export function multipleSum (...num) { export function multipleSum (...num) {
let sum = 0 let sum = 0
@ -35,4 +43,5 @@ export default function (Vue) {
Vue.prototype.deleteArrayAllItems = deleteArrayAllItems Vue.prototype.deleteArrayAllItems = deleteArrayAllItems
Vue.prototype.debounce = debounce Vue.prototype.debounce = debounce
Vue.prototype.multipleSum = multipleSum Vue.prototype.multipleSum = multipleSum
Vue.prototype.randomExtend = randomExtend
} }