uni-app+typescript封装接口异常情况Toast处理
1.定义一个SystemSevice类,封装一个errorHanlder方法,处理error
interface ICustomError {
message?:string
title?:string
alertType?:string
}
errorHanlder(e:Error | ICustomError){
//断言,我知道传进来的是 ICustomError类型的错误
const error=e as ICustomError;
switch(error.alertType){
case 'toast':
uni.showToast({
})
break;
}
}
浙公网安备 33010602011771号