.then

  1. <script>
  2. var http01 = Promise.resolve(1001);
  3. var http02 = Promise.resolve("detail");
  4. http01.then(res=>{
  5. console.log(res)
  6. return res;
  7. }).then(id=>{
  8. /* 得到id值发送http请求 */
  9. http02.then(res=>{
  10. console.log("detail")
  11. })
  12. })
  13. </script>

await

  1. <script>
  2. var http01 = Promise.resolve(1001);
  3. var http02 = Promise.resolve("detail");
  4. async function show(){
  5. var id = await http01;
  6. console.log(id);
  7. /* 根据id去发送http请求 */
  8. var detail = await http02;
  9. console.log(detail)
  10. }
  11. show()
  12. </script>