let btn = document.getElementById('btn');
btn.addEventListener('click',function(){
// setTimeout(()=>{
// let n = Math.floor((Math.random() * 100) + 1);
// if(n<=30){
// console.log(n,'中奖')
// }else{
// console.log(n,'擦肩而过')
// }
// },1000)
let p = new Promise((resolve,reject)=>{
setTimeout(()=>{
let n = Math.floor((Math.random() * 100) + 1);
console.log(n)
if(n<=30){
resolve(n);
}else{
reject(n);
}
},1000)
});
p.then((params)=>{
alert(params+'中奖')
},(a)=>{
alert(a+'擦肩而过')
})
})
<div id="father">
<button id="btn">点击抽奖</button>
</div>