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

网站建设与管理需要什么软件有哪些内容代做网站公司哪家好

网站建设与管理需要什么软件有哪些内容,代做网站公司哪家好,临海市建设局官网站,什么是网站建设的建议1、promise链式调用 /*** 目标#xff1a;把回调函数嵌套代码#xff0c;改成Promise链式调用结构* 需求#xff1a;获取默认第一个省#xff0c;第一个市#xff0c;第一个地区并展示在下拉菜单中*/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)})/script5、axios返回的是一个promise对象axios.then方法也返回一个新promise对象 script srchttps://cdn.jsdelivr.net/npm/axios/dist/axios.min.js/scriptscriptconst 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)/script6、案例 需求同时展示数据 返回的是一个个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 classitemh3${itemData.name}/h3ul${children.map(item {return lia hrefjavascript:;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 classitem// h3${dataObj.name}/h3// ul// ${dataObj.children.map(item {// return li// a hrefjavascript:;// 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://wiki.neutronadmin.com/news/395664/

相关文章:

  • 西斗门的网站建设线上软装设计师
  • 宁波网站建设怎么建设网站改版不换域名
  • 手机免费制作自己的网站东平企业建站公司
  • 手机版网站制作应用门户网站开发视频
  • 怎么用自己电脑做服务器发布网站吗网络服务示范区创建情况
  • 做网站 价格河南省建设厅网站首页
  • 网站建设到维护网站开发人员是什么
  • 网站空间免费 优帮云东莞网站的建设
  • 百度网站的域名地址自己做的网站如何调入dede
  • 中山建网站咨询电话网站制作做站长挣钱
  • 企业怎么建立网站怎么做带数据库的网站
  • 优化网站工具上海网站开发制
  • 中铁雄安建设有限公司网站镇江网页设计工作室
  • 坑梓网站建设包括哪些全国信用企业公示平台官网
  • 免费网站推广方式怎么样做游戏网站
  • 广告网站设计模板之家免费官网下载
  • wordpress该站点地址做网站有必要?
  • 网站建设维护项目一级做a视频在线观看网站
  • 百度云wordpress建站北京英众数字科技有限公司
  • 泉州网站建设维护网店营销模式
  • 魔鬼做交易网站广告海报
  • 建个地方门户网站要多少钱获取网站浏览者手机号
  • wordpress图片站模板下载泛微oa手机版
  • 万网网站备案查询wordpress音频在移动端播放不
  • 网站怎么做盈利wordpress 邮件文本
  • 柳州做网站设计的公司建设信用卡银行积分商城网站
  • 网站运营职业分析优惠券网站开发哪家好
  • 温州网站建设的公司网站首页 seo
  • 微信网站开发服务黄石网站建设推荐
  • 临沂网站建设报价建设网站我们重中之重-用户体验