學習不能溫故而知新,就總是在遺忘的路上。。。
隨機生成一個隨機數是什麼來着?
數組的sort方法是是什麼意思來着?
再這麼下去,都快忘了自己是誰了,Oh,My God!
Math.random() // 隨機生成一個0~1之間的隨機數(包括0但不包括1)
Math.round(Math.random(m-n)+n //生成一個m到n之間的隨機數
export default {
data(){
return {
this.newlyWarning = [12,25,24,36,49,56,12,54,78]
}
}
},
methods: {
this.newlyWarning = this.newlyWarning.sort(function(){ // 數組隨機打亂
return (0.5 - Math.random());
});
}
注:技術參考 隨機打亂數組