其他分享
首页 > 其他分享> > 兜底方案的常见的错误

兜底方案的常见的错误

作者:互联网

1、错误写法

function abc(txt){

try{

throw ("立刻出错")

}

catch(err){

alert(txt.value) //加入这里出错,会出现白屏

}

}

 

2、正确写法

function abc(txt){

try{

throw ("立刻出错")

}

catch(err){

alert((txt||{}).value||"出错了,请排查问题") //加入这里出错,会出现白屏

}

}

 

标签:function,abc,错误,常见,alert,兜底,出错,catch,txt
来源: https://www.cnblogs.com/sexintercourse/p/15660780.html