promise 實際使用
例項2const p = new promise((resolve, reject) => )
.then(() => else
});});
const c = (res) => , 1000);
});};
p.then((res) => )
.then((r) => )
.catch((err) => )
例項3// 封裝
}// 呼叫
ajax('/prefix/entity1/action1',null, function(resp)).then(
ajax('/prefix/entity2/action2', somedata, function(resp)
).then(
initvue() ;
).then(
//do something else
)
4. async/await 初嚐場景一:先呼叫getdata1,再呼叫getdata2,再呼叫getdata3 ...
//建立乙個promise例項,獲取資料。並把資料傳遞給處理函式resolve和reject。需要注意的是promise在宣告的時候就執行了。
var getdata1=new promise(function(resolve,reject)else
}});
})var getdata2= new promise(function(resolve,reject)else
}});
})var getdata3=new promise(function(resolve,reject)else
}});
})getdata1.then(function(res)).then(function(res)).then(function(res)).cache(function(error))
場景二:getdata3的執行依賴getdata1和getdata2
//promise的all方法,等陣列中的所有promise物件都完成執行
promise.all([getdata1,getdata2]).then(function([resultjson1,resultjson2]))
5. promise 實現4的功能const query = async () => ,
})// eslint-disable-next-line no-shadow
.then(() => else
});// this.props.actions.queryone();
};const queryson = async () => ,
isloading: true,
}).then(() => );
} else
});};
const initquery = async () => ;
initquery();
// promise
const query = new promise((resolve, reject) => , resolve);
// fetchapi.fetch(,
// })
// // eslint-disable-next-line no-shadow
// .then(() => else
// });
});const queryson = (r) => ,
isloading: true,
}).then(() => else
});});
};query.then((res) => ).then(result => this.setstate());
mysql IFNULL實際使用
表 srm supplier srm sup company,srm company 關係 srm supplier 一對多 srm sup company,srm company 多對一 srm sup company 問題 取所有srm supplier資訊,其中companyname存在srm...
Linux mount實際使用
檢視所有檔案系統 裝置 fdisk l 1.當要重新掛載乙個檔案系統時 裝置 可以直接 mount o remount,rw dev sdb9 檔案系統 mnt sdb9 目錄 也可以 umount mnt sdb9 fdisk l 作用是找到所有的檔案系統,如果用df或者mount命令不能看到沒有...
如何實際使用redis java
之前我已經介紹過了redis資料庫 這次介紹它如何使用 要使用鏈結池我們需要匯入兩個架包 commons pool jedis 先給出工具類 public class jedisutils 獲取連線的方法 public static jedis getjedis 釋放連線 public static...