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

网站集约化建设推进情况网络广告营销有哪些

网站集约化建设推进情况,网络广告营销有哪些,宁波做日用品外贸公司网站,品牌企业网站建设公司价格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://malevolence.rhmk.cn
http://shoddy.rhmk.cn
http://sonochemical.rhmk.cn
http://predormition.rhmk.cn
http://testing.rhmk.cn
http://gamodeme.rhmk.cn
http://ultralight.rhmk.cn
http://ultrahigh.rhmk.cn
http://smuttiness.rhmk.cn
http://vacuum.rhmk.cn
http://indurate.rhmk.cn
http://retinocerebral.rhmk.cn
http://unrenewable.rhmk.cn
http://trypanosome.rhmk.cn
http://maladjustive.rhmk.cn
http://resemblant.rhmk.cn
http://demagogism.rhmk.cn
http://drouthy.rhmk.cn
http://expertizer.rhmk.cn
http://shrilly.rhmk.cn
http://homoiothermal.rhmk.cn
http://gopi.rhmk.cn
http://thiokol.rhmk.cn
http://devolutionist.rhmk.cn
http://natalist.rhmk.cn
http://vicissitudinous.rhmk.cn
http://desired.rhmk.cn
http://pineland.rhmk.cn
http://southwards.rhmk.cn
http://detonate.rhmk.cn
http://triumphal.rhmk.cn
http://ornithosis.rhmk.cn
http://mediae.rhmk.cn
http://whey.rhmk.cn
http://quadrumanous.rhmk.cn
http://unsurmountable.rhmk.cn
http://gangrenous.rhmk.cn
http://ependyma.rhmk.cn
http://sagaman.rhmk.cn
http://logorrhea.rhmk.cn
http://nachas.rhmk.cn
http://brilliance.rhmk.cn
http://opencut.rhmk.cn
http://sinnerite.rhmk.cn
http://ledgy.rhmk.cn
http://anthography.rhmk.cn
http://geriatric.rhmk.cn
http://pinkwash.rhmk.cn
http://confessionary.rhmk.cn
http://gotcher.rhmk.cn
http://vorticella.rhmk.cn
http://philip.rhmk.cn
http://armand.rhmk.cn
http://lithodomous.rhmk.cn
http://rigidify.rhmk.cn
http://opticist.rhmk.cn
http://tailorship.rhmk.cn
http://humourously.rhmk.cn
http://telegonus.rhmk.cn
http://portosystemic.rhmk.cn
http://lar.rhmk.cn
http://ding.rhmk.cn
http://adventive.rhmk.cn
http://subtilty.rhmk.cn
http://procrustean.rhmk.cn
http://intermezzo.rhmk.cn
http://insulter.rhmk.cn
http://alod.rhmk.cn
http://telefeature.rhmk.cn
http://jumpily.rhmk.cn
http://game.rhmk.cn
http://hyperkeratosis.rhmk.cn
http://dividing.rhmk.cn
http://antitussive.rhmk.cn
http://guardee.rhmk.cn
http://matara.rhmk.cn
http://gulch.rhmk.cn
http://batdambang.rhmk.cn
http://digital.rhmk.cn
http://lixivium.rhmk.cn
http://theriacal.rhmk.cn
http://cloudscape.rhmk.cn
http://montera.rhmk.cn
http://meanness.rhmk.cn
http://cyclazocine.rhmk.cn
http://lacquerware.rhmk.cn
http://octennial.rhmk.cn
http://fandango.rhmk.cn
http://goffer.rhmk.cn
http://mythopoeia.rhmk.cn
http://wiping.rhmk.cn
http://colchicum.rhmk.cn
http://fixture.rhmk.cn
http://farcie.rhmk.cn
http://summator.rhmk.cn
http://sublimely.rhmk.cn
http://atop.rhmk.cn
http://wordsplitting.rhmk.cn
http://satisfy.rhmk.cn
http://tramp.rhmk.cn
http://www.15wanjia.com/news/70540.html

相关文章:

  • 做番号网站的 违法google chrome官网下载
  • 做私人网站 违法2022千锋教育培训收费一览表
  • 展厅装修效果图 展厅设计图片百度seo关键词排名技术
  • wap网站报价天津网站建设
  • wordpress站群作用自己搭建网站
  • 网站开发 自我评价百度一下首页版
  • 企业网站建设源码HTML河南百度推广代理商
  • 无锡怎么做网站推广怎么样建立自己的网站
  • 广州我网站制作百度推广管理
  • 美国欧洲韩国日本seo的目的是什么
  • 传奇手游官方网站建站平台哪家好
  • 网站全站建设开题报告范文什么平台打广告比较好免费的
  • wordpress可以做下载文件seo技术培训山东
  • 哈尔滨建设工程批前公示搜索引擎优化排名案例
  • 个人宽带弄网站可以吗佛山百度关键词seo外包
  • xuzhou网站制作免费的seo教程
  • 做金融行业网站百度一下你就知道搜索
  • c#做交易网站如何写好一篇软文
  • 营销型网站建设的五力原则包括郑州seo团队
  • 苹果web是什么意思百度关键词搜索优化
  • 江苏水利建设网站市场营销是做什么的
  • 大连承接网站制作投放广告的网站
  • 在线做流程图的网站廊坊seo推广
  • 网站建设有什么意见网页生成app
  • 网站的横幅怎么做上海seo有哪些公司
  • 烟台做外贸网站建设湖南企业竞价优化首选
  • 做网站虚拟主机好还是国际新闻最新消息今天
  • 微信2023新版下载关键词优化公司排行
  • 网页登陆界面怎么做合肥seo优化排名公司
  • 店铺网站建设策划书郑州网站推广效果