async,await只能处理正常的promise,返回已经兑现的promise,不能处理已拒绝的promise
async created(){
//调用后端fetch接口查询数据
let data = await fetch({
url:'goods-type/list/all',
method:'get',
})
}
为了处理已拒绝的promise,加try,catch
async created() {
try {
//调用后端接口查询数据
let data = await fetch({
url: "goods-type/list/all",
method: "get",
});
} catch (e) {
console.log(e);
}
},