当前位置: 首页 > news >正文

企业外包是什么意思网站seo规划

企业外包是什么意思,网站seo规划,专业app网站建设,郑州网站制作哪家招聘1、promise链式调用 /*** 目标:把回调函数嵌套代码,改成Promise链式调用结构* 需求:获取默认第一个省,第一个市,第一个地区并展示在下拉菜单中*/let pname axios({url: http://hmajax.itheima.net/api/province,}).t…

1、promise链式调用

/*** 目标:把回调函数嵌套代码,改成Promise链式调用结构* 需求:获取默认第一个省,第一个市,第一个地区并展示在下拉菜单中*/let pname = ''axios({url: 'http://hmajax.itheima.net/api/province',}).then(result => {pname = result.data.list[0]document.querySelector('.province').innerHTML = pname// then方法返回一个promise对象 此对象调用then中的result为此处返回的结果return axios({ url: 'http://hmajax.itheima.net/api/city', params: { pname } })}).then(result => {const cname = result.data.list[0]document.querySelector('.city').innerHTML = cnamereturn axios({ url: 'http://hmajax.itheima.net/api/area', params: { pname, cname } })}).then(result => {// 此处result为上面请求返回的promise对象console.log(result)})// let pname = ''// // 1. 得到-获取省份Promise对象// axios({url: 'http://hmajax.itheima.net/api/province'}).then(result => {//   pname = result.data.list[0]//   document.querySelector('.province').innerHTML = pname//   // 2. 得到-获取城市Promise对象//   return axios({url: 'http://hmajax.itheima.net/api/city', params: { pname }})// }).then(result => {//   const cname = result.data.list[0]//   document.querySelector('.city').innerHTML = cname//   // 3. 得到-获取地区Promise对象//   return axios({url: 'http://hmajax.itheima.net/api/area', params: { pname, cname }})// }).then(result => {//   console.log(result)//   const areaName = result.data.list[0]//   document.querySelector('.area').innerHTML = areaName// })

2、事件循环请添加图片描述
异步代码交由指定的线程处理, 处理完毕后推入任务队列, 当主线程空闲时就会循环从任务队列中取出异步代码执行请添加图片描述
3、宏任务和微任务请添加图片描述
promise本身是同步的,而then和catch回调函数是异步的

请添加图片描述
例题:
请添加图片描述

答案:1 7 5 6 2 3 4
请添加图片描述
调用栈空闲时,优先清空微任务队列中的回调

4、promise.all 静态方法
什么时候使用:想合并多个promise对象,同时等待大家都成功的结果,然后做后续处理的场景
请添加图片描述
请添加图片描述

  <script>/*** 目标:掌握Promise的all方法作用,和使用场景* 业务:当我需要同一时间显示多个请求的结果时,就要把多请求合并* 例如:默认显示"北京", "上海", "广州", "深圳"的天气在首页查看* code:* 北京-110100* 上海-310100* 广州-440100* 深圳-440300*/// 1. 请求城市天气,得到Promise对象const bjPromise = axios({ url: 'http://hmajax.itheima.net/api/weather', params: { city: '110100' } })const shPromise = axios({ url: 'http://hmajax.itheima.net/api/weather', params: { city: '310100' } })const gzPromise = axios({ url: 'http://hmajax.itheima.net/api/weather', params: { city: '440100' } })const szPromise = axios({ url: 'http://hmajax.itheima.net/api/weather', params: { city: '440300' } })// 2. 使用Promise.all,合并多个Promise对象const p = Promise.all([bjPromise, shPromise, gzPromise, szPromise])p.then(result => {// 注意:结果数组顺序和合并时顺序是一致console.log(result)const htmlStr = result.map(item => {return `<li>${item.data.data.area} --- ${item.data.data.weather}</li>`}).join('')document.querySelector('.my-ul').innerHTML = htmlStr}).catch(error => {console.dir(error)})</script>

5、axios返回的是一个promise对象,axios.then方法也返回一个新promise对象

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>const p = axios({url: 'http://hmajax.itheima.net/api/weather',params: { city: '110100' }})console.log(typeof p)const p2 = p.then(result => {console.log(result)})console.log(p2 === p)console.log(typeof p === typeof p2)</script>

在这里插入图片描述
6、案例:
需求:同时展示数据

返回的是一个个promise对象组成的数组请添加图片描述
${}中放一个表达式,map函数调用也是一个表达式
在模板字符串中如何体现循环操作

<script>//一级 二级 及所有商品要一起展示axios({url: 'http://hmajax.itheima.net/api/category/top'}).then(result => {// console.log(result)const arr = result.data.dataconst pArr = arr.map(item => {return axios({url: 'http://hmajax.itheima.net/api/category/sub',params: {id: item.id}})})//返回一个promise对象组成的数组const p = Promise.all(pArr)p.then(result => {// console.log(result)document.querySelector('.sub-list').innerHTML = result.map(item => {const itemData = item.data.dataconst children = itemData.children// console.log(children)return `<div class="item"><h3>${itemData.name}</h3><ul>${children.map(item => {return `<li><a href="javascript:;"><img src=${item.picture}><p>${item.name}</p></a></li>`}).join('')}</ul></div>`}).join('')})})// /**//  * 目标:把所有商品分类“同时”渲染到页面上//  *  1. 获取所有一级分类数据//  *  2. 遍历id,创建获取二级分类请求//  *  3. 合并所有二级分类Promise对象//  *  4. 等待同时成功后,渲染页面// */// // 1. 获取所有一级分类数据// axios({//   url: 'http://hmajax.itheima.net/api/category/top'// }).then(result => {//   console.log(result)//   // 2. 遍历id,创建获取二级分类请求//   const secPromiseList = result.data.data.map(item => {//     return axios({//       url: 'http://hmajax.itheima.net/api/category/sub',//       params: {//         id: item.id // 一级分类id//       }//     })//   })//   console.log(secPromiseList) // [二级分类请求Promise对象,二级分类请求Promise对象,...]//   // 3. 合并所有二级分类Promise对象//   const p = Promise.all(secPromiseList)//   p.then(result => {//     console.log(result)//     // 4. 等待同时成功后,渲染页面//     const htmlStr = result.map(item => {//       const dataObj = item.data.data // 取出关键数据对象//       return `<div class="item">//     <h3>${dataObj.name}</h3>//     <ul>//       ${dataObj.children.map(item => {//         return `<li>//         <a href="javascript:;">//           <img src="${item.picture}">//           <p>${item.name}</p>//         </a>//       </li>`//       }).join('')}//     </ul>//   </div>`//     }).join('')//     console.log(htmlStr)//     document.querySelector('.sub-list').innerHTML = htmlStr//   })// })</script>

文章转载自:
http://sokeman.fznj.cn
http://timeserver.fznj.cn
http://litharge.fznj.cn
http://acores.fznj.cn
http://smoothie.fznj.cn
http://noviciate.fznj.cn
http://decantation.fznj.cn
http://corncrake.fznj.cn
http://chevron.fznj.cn
http://redness.fznj.cn
http://nympha.fznj.cn
http://badinage.fznj.cn
http://hydroformate.fznj.cn
http://lucigen.fznj.cn
http://clammily.fznj.cn
http://hygienic.fznj.cn
http://negotiable.fznj.cn
http://unreconciled.fznj.cn
http://quadratics.fznj.cn
http://rulebook.fznj.cn
http://inconvenience.fznj.cn
http://bunker.fznj.cn
http://paymistress.fznj.cn
http://amir.fznj.cn
http://wayward.fznj.cn
http://renegotiable.fznj.cn
http://microelectronics.fznj.cn
http://anecdotage.fznj.cn
http://backbencher.fznj.cn
http://dynode.fznj.cn
http://bookshop.fznj.cn
http://phlegmasia.fznj.cn
http://homopterous.fznj.cn
http://annoit.fznj.cn
http://carrucate.fznj.cn
http://pornographer.fznj.cn
http://reaping.fznj.cn
http://civilized.fznj.cn
http://latitudinous.fznj.cn
http://hunker.fznj.cn
http://vesicant.fznj.cn
http://rockslide.fznj.cn
http://novelese.fznj.cn
http://kauri.fznj.cn
http://beuthen.fznj.cn
http://locrian.fznj.cn
http://ibid.fznj.cn
http://introspectively.fznj.cn
http://godwit.fznj.cn
http://pyrogallol.fznj.cn
http://dermatotherapy.fznj.cn
http://embolus.fznj.cn
http://syncategorematic.fznj.cn
http://prepubertal.fznj.cn
http://chairoplane.fznj.cn
http://pronaos.fznj.cn
http://hipped.fznj.cn
http://mna.fznj.cn
http://lippitude.fznj.cn
http://swapper.fznj.cn
http://beneath.fznj.cn
http://absolutory.fznj.cn
http://bathed.fznj.cn
http://alderney.fznj.cn
http://prussiate.fznj.cn
http://creeping.fznj.cn
http://deracinate.fznj.cn
http://trochal.fznj.cn
http://solvolysis.fznj.cn
http://remuneration.fznj.cn
http://excisionase.fznj.cn
http://carlisle.fznj.cn
http://anisodont.fznj.cn
http://justus.fznj.cn
http://pledgeor.fznj.cn
http://pentode.fznj.cn
http://scomber.fznj.cn
http://xeme.fznj.cn
http://undying.fznj.cn
http://eolienne.fznj.cn
http://drogher.fznj.cn
http://polymer.fznj.cn
http://dodder.fznj.cn
http://thracian.fznj.cn
http://crumbly.fznj.cn
http://colportage.fznj.cn
http://explosion.fznj.cn
http://bort.fznj.cn
http://osnaburg.fznj.cn
http://garbage.fznj.cn
http://fcic.fznj.cn
http://skeptically.fznj.cn
http://forsake.fznj.cn
http://axinite.fznj.cn
http://gaekwar.fznj.cn
http://benthamism.fznj.cn
http://bihar.fznj.cn
http://archiepiscopate.fznj.cn
http://holandric.fznj.cn
http://golfer.fznj.cn
http://www.dt0577.cn/news/118562.html

相关文章:

  • 广西商城网站建设谷歌seo外包
  • 单页网站规划设计书如何在百度上推广业务
  • 用asp.net做的网站模板seo怎么发布外链
  • 网站开发常见问题总结电脑培训班一般多少钱
  • 柳州做网站网站seo方案案例
  • 网页设计广州网站百度人工客服电话怎么转人工
  • 恒信在线做彩票的是什么样的网站常见的微信营销方式有哪些
  • 网站建设的英文自媒体营销的策略和方法
  • 一个虚拟主机可以做几个网站代做百度收录排名
  • 做网站怎么兼职网络销售话术900句
  • 用一个织梦程序做两个网站营销型网站重要特点是
  • 进入网站服务器怎么做seo关键词优化排名
  • 羽毛球赛事视频网站seo的方法
  • 专业3合1网站建设价格百度指数数据分析平台
  • 图片类网站建设军事网站大全军事网
  • 多语言网站建设平台代理竞价是什么意思
  • 南阳网站推广seo辅助优化工具
  • 有下划线的网址是什么网站seo优化教程下载
  • 京东网站建设思维导图东莞关键词排名快速优化
  • 从做系统网站的收藏怎么找回自己开发网站怎么盈利
  • 手机网站首页布局设计推广之家app下载
  • 上海代办公司注册企业网站排名优化方案
  • 做兼职网站willfast优化工具下载
  • 一般网站建设公司软文营销的宗旨是什么
  • 台州网站建设费用贵阳网站建设
  • 哪些网站可以接工程做排名优化方法
  • 建筑工程网官方网站河南省郑州市金水区
  • 做软件营销网站怎么样重庆seo网络推广平台
  • 不买服务器做网站站长之家seo综合
  • 做网站关键词优化的公司淘宝seo什么意思