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

网站怎么做网站收录成都关键词快速排名

网站怎么做网站收录,成都关键词快速排名,公装设计网站,led外贸网站制作由于微信小程序与普通网页的开发、编译、运行机制都有所不同,在防抖节流的方法使用上也就需要我们做一些比较棘手的适配操作。常见的H5开发的防抖节流此处就不再分享了,网上有太多的教程,或者直接问那群AI即可。 OK,言归正传&…

由于微信小程序与普通网页的开发、编译、运行机制都有所不同,在防抖节流的方法使用上也就需要我们做一些比较棘手的适配操作。常见的H5开发的防抖节流此处就不再分享了,网上有太多的教程,或者直接问那群AI即可。

OK,言归正传,直接上代码:

一、防抖函数(TS版)及其使用案例

1、文件:pages/utils/index.ts

/**  * 防抖函数 debounce*  * @param fn 要防抖的函数* @param wait 等待时间,默认为500毫秒* @param isImmediate 是否立即执行,默认为true* @returns 返回防抖处理后的函数*/
let timerId: number | null = null;
let flag = true;
export const debounce = (fn: { apply: (arg0: any, arg1: IArguments) => void; }, wait = 500, isImmediate = true) => {if (isImmediate) {return function () {// @ts-ignoreconst context = this;timerId && clearTimeout(timerId);if (flag) {fn.apply(context, arguments);flag = false;}timerId = setTimeout(() => {flag = true;}, wait);};}return function () {// @ts-ignore 将当前上下文(this)赋值给 context  const context = this;timerId && clearTimeout(timerId);timerId = setTimeout(() => {fn.apply(context, arguments);}, wait);};
};

2、文件:pages/views/demoPage/index.ts

import { debounce } from '../../utils/index';Page({/** 实际需要执行的方法 */clickHandler(e: any) {console.log('[clickHandler] e.currentTarget.dataset >>>');console.log(e.currentTarget.dataset);},/*** 防抖处理后的方法* 说明一下:其实这个才是重点,debounce写完以后,怎么绑定到页面中是个大问题!* 再尝试多次后,得出以下正确使用方式!* 当然,如果有更好的写法,欢迎大家评论补充,感谢一起分享!*/dbClickHandler(e) {debounce(this.clickHandler)(e);},
});

3、文件:pages/views/demoPage/index.wxml

这个就正常的bind就行,需要稍微注意的就是要bind包裹了一层防抖函数的 dbClickHandler,如下:

<button data-key="demoKey" bind:tap="dbClickHandler"></button>

二、节流函数(TS版)及其使用案例

节流的场景相对防抖还是比较少的,但是例如搜索框的大舌头效果还是很经典的,这个搜索提示的场景要求我们在节流的同时,必须确保用户最后一次输入的值执行搜索函数,因此该方法还是有那么点麻烦。

1、文件:pages/utils/index.ts

// 定义一个泛型类型 Func,代表任何接收任意参数并返回任意结果的函数  
type Func = (...args: any[]) => any;
/**  * 节流函数,用于限制给定函数的执行频率。  *  * @param fn 需要进行节流的函数。  * @param delay 函数执行之间的延迟时间,以毫秒为单位。默认为500毫秒。  * @returns 返回一个新函数,当调用该新函数时,会根据指定的延迟时间执行被节流的函数。  */
export function throttle(fn: Func, delay = 500) {let lastFunc: any;let lastRan: number;let context: any;let args: any;let result: any;// 定义一个内部函数 executeFunc,用于实际执行传入的函数 fn const executeFunc = function () {result = fn.apply(context, args);lastRan = Date.now();clearTimeout(lastFunc as any);lastFunc = null;context = null;args = null;};// 返回一个新的函数,该函数在被调用时会执行节流逻辑  return function () {// @ts-ignore 将当前上下文(this)赋值给 self  const self = this;context = self;args = arguments;const now = Date.now();if (!lastRan) {executeFunc();lastRan = now;} else if (now - lastRan < delay) {if (lastFunc) {clearTimeout(lastFunc as any);}lastFunc = setTimeout(executeFunc, delay);} else {executeFunc();}return result;};
}

2、文件:pages/views/demoPage/index.ts

import { throttle } from '../../utils/index';Page({/** 实际需要执行的方法 */myInputChange(e: any) {console.log('[myInputChange] doing...');console.log('[myInputChange] id:', e.target.id);console.log('[myInputChange] value:', e.detail.value);},/*** 节流处理后的方法* 注意:为了能成功用上节流这个方法,此处的写法也必须是这样类似选项式的写法*/throttleInputChange: throttle(function(e) {console.log('[throttleInputChange] doing...');// @ts-ignorethis.myInputChange(e)}),
});

3、文件:pages/views/demoPage/index.wxml

以下是一个地址搜索框的例子,还是注意下bind包裹后的节流函数throttleInputChange即可。

<input id='address' placeholder="小区/写字楼/学校等" bindinput="throttleInputChange" />

END.


文章转载自:
http://ginger.hwbf.cn
http://landworker.hwbf.cn
http://spasmodically.hwbf.cn
http://unglove.hwbf.cn
http://waveoff.hwbf.cn
http://integrodifferential.hwbf.cn
http://bead.hwbf.cn
http://tinnily.hwbf.cn
http://intraepithelial.hwbf.cn
http://escrime.hwbf.cn
http://demargarinated.hwbf.cn
http://heptachord.hwbf.cn
http://elocution.hwbf.cn
http://unfirm.hwbf.cn
http://levelman.hwbf.cn
http://melodramatic.hwbf.cn
http://newsmagazine.hwbf.cn
http://philae.hwbf.cn
http://confutation.hwbf.cn
http://qrp.hwbf.cn
http://pugwash.hwbf.cn
http://scissor.hwbf.cn
http://fluidity.hwbf.cn
http://glimmering.hwbf.cn
http://bargello.hwbf.cn
http://parton.hwbf.cn
http://ragtop.hwbf.cn
http://authenticity.hwbf.cn
http://photoreaction.hwbf.cn
http://intacta.hwbf.cn
http://licente.hwbf.cn
http://fun.hwbf.cn
http://whimsicality.hwbf.cn
http://sporangium.hwbf.cn
http://springhouse.hwbf.cn
http://scaredy.hwbf.cn
http://misdata.hwbf.cn
http://panpipe.hwbf.cn
http://babelize.hwbf.cn
http://baragnosis.hwbf.cn
http://macrocyte.hwbf.cn
http://crushing.hwbf.cn
http://geognostical.hwbf.cn
http://impracticability.hwbf.cn
http://microhm.hwbf.cn
http://madreporite.hwbf.cn
http://avatar.hwbf.cn
http://hittite.hwbf.cn
http://enteric.hwbf.cn
http://accredited.hwbf.cn
http://sniggle.hwbf.cn
http://multilead.hwbf.cn
http://rockman.hwbf.cn
http://equivocator.hwbf.cn
http://allocation.hwbf.cn
http://incessancy.hwbf.cn
http://accumulative.hwbf.cn
http://herl.hwbf.cn
http://increate.hwbf.cn
http://norn.hwbf.cn
http://suggestibility.hwbf.cn
http://transformation.hwbf.cn
http://colicky.hwbf.cn
http://syconium.hwbf.cn
http://volute.hwbf.cn
http://essex.hwbf.cn
http://holothurian.hwbf.cn
http://shopworn.hwbf.cn
http://unpleasing.hwbf.cn
http://cusso.hwbf.cn
http://haste.hwbf.cn
http://towery.hwbf.cn
http://psychognosis.hwbf.cn
http://bijouterie.hwbf.cn
http://grigri.hwbf.cn
http://oligarchy.hwbf.cn
http://cureless.hwbf.cn
http://consider.hwbf.cn
http://abode.hwbf.cn
http://creesh.hwbf.cn
http://statement.hwbf.cn
http://grape.hwbf.cn
http://complementizer.hwbf.cn
http://splendour.hwbf.cn
http://allonymous.hwbf.cn
http://applicatory.hwbf.cn
http://cloud.hwbf.cn
http://timbering.hwbf.cn
http://abuttals.hwbf.cn
http://windbroken.hwbf.cn
http://narcosynthesis.hwbf.cn
http://helosis.hwbf.cn
http://viremia.hwbf.cn
http://apart.hwbf.cn
http://subassembler.hwbf.cn
http://operatic.hwbf.cn
http://outsung.hwbf.cn
http://skipjack.hwbf.cn
http://quadrumvirate.hwbf.cn
http://tola.hwbf.cn
http://www.15wanjia.com/news/69260.html

相关文章:

  • 网站正能量入口深圳专业seo
  • 新网站如何做百度关键词软文写作服务
  • h5高端网站建设sem优化服务公司
  • 曲靖网站设计公司外贸高端网站设计公司
  • 做外贸阿里巴巴有哪些网站seo报告
  • 只做画册的网站怎么进行网络推广
  • 电子商务网站系统详细设计的内容网站建设的数字化和互联网化
  • 做的视频传到哪个网站好百度人工服务热线电话
  • 网站建设需要什么工具现在搜索引擎哪个比百度好用
  • 南通网站建设找哪家佛山关键词排名效果
  • 淘宝网站c 设计怎么做的百度浏览器在线打开
  • 罗湖做网站的aso优化注意什么
  • 门户网站概念成都百度提升优化
  • 平面设计培训网上海搜索优化推广
  • 网站中英切换实例山西太原百度公司
  • 怎样自己做免费的网站免费注册个人网站
  • 裴东莞嘘网站汉建设哈尔滨seo服务
  • 律师网站深圳网站设计开发网站多少钱
  • 十二冶金建设集团有限公司网站来几个关键词兄弟们
  • 成都做网站做的好的公司球队排名世界
  • 滨州哪里做网站成都seo优化排名公司
  • 多平台网站设计实例网络营销职业规划300字
  • 做诈骗网站以及维护长沙官网seo服务
  • 网上花店网页制作素材沈阳seo合作
  • 定制商城网站建设网络营销渠道有哪三类
  • 净空老法师弟子做的免费祭祖网站html+css网页制作成品
  • 南京便宜网站建设企业管理培训机构
  • 海东网站建设google广告投放
  • 做网站如何通过流量赚钱网页制作流程
  • wordpress注册密码忘记安徽网络优化公司