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

做彩妆发哪个网站浏览量高seo学校培训班

做彩妆发哪个网站浏览量高,seo学校培训班,如何辨别官方网站,wordpresscom下载文章目录 前言介绍代码场景例子优缺点后言 前言 hello world欢迎来到前端的新世界 😜当前文章系列专栏:前端设计模式 🐱‍👓博主在前端领域还有很多知识和技术需要掌握,正在不断努力填补技术短板。(如果出现错误&#…

文章目录

  • 前言
  • 介绍
  • 代码
  • 场景例子
  • 优缺点
  • 后言

前言

hello world欢迎来到前端的新世界


😜当前文章系列专栏:前端设计模式
🐱‍👓博主在前端领域还有很多知识和技术需要掌握,正在不断努力填补技术短板。(如果出现错误,感谢大家指出)🌹
💖感谢大家支持!您的观看就是作者创作的动力

介绍

  • 策略模式简单描述就是:对象有某个行为,但是在不同的场景中,该行为有不同的实现算法。把它们一个个封装起来,并且使它们可以互相替换

代码

<html>
<head><title>策略模式-校验表单</title><meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body><form id = "registerForm" method="post" action="http://xxxx.com/api/register">用户名:<input type="text" name="userName">密码:<input type="text" name="password">手机号码:<input type="text" name="phoneNumber"><button type="submit">提交</button></form><script type="text/javascript">// 策略对象const strategies = {isNoEmpty: function (value, errorMsg) {if (value === '') {return errorMsg;}},isNoSpace: function (value, errorMsg) {if (value.trim() === '') {return errorMsg;}},minLength: function (value, length, errorMsg) {if (value.trim().length < length) {return errorMsg;}},maxLength: function (value, length, errorMsg) {if (value.length > length) {return errorMsg;}},isMobile: function (value, errorMsg) {if (!/^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|17[7]|18[0|1|2|3|5|6|7|8|9])\d{8}$/.test(value)) {return errorMsg;}                }}// 验证类class Validator {constructor() {this.cache = []}add(dom, rules) {for(let i = 0, rule; rule = rules[i++];) {let strategyAry = rule.strategy.split(':')let errorMsg = rule.errorMsgthis.cache.push(() => {let strategy = strategyAry.shift()strategyAry.unshift(dom.value)strategyAry.push(errorMsg)return strategies[strategy].apply(dom, strategyAry)})}}start() {for(let i = 0, validatorFunc; validatorFunc = this.cache[i++];) {let errorMsg = validatorFunc()if (errorMsg) {return errorMsg}}}}// 调用代码let registerForm = document.getElementById('registerForm')let validataFunc = function() {let validator = new Validator()validator.add(registerForm.userName, [{strategy: 'isNoEmpty',errorMsg: '用户名不可为空'}, {strategy: 'isNoSpace',errorMsg: '不允许以空白字符命名'}, {strategy: 'minLength:2',errorMsg: '用户名长度不能小于2位'}])validator.add(registerForm.password, [ {strategy: 'minLength:6',errorMsg: '密码长度不能小于6位'}])validator.add(registerForm.phoneNumber, [{strategy: 'isMobile',errorMsg: '请输入正确的手机号码格式'}])return validator.start()}registerForm.onsubmit = function() {let errorMsg = validataFunc()if (errorMsg) {alert(errorMsg)return false}}</script>
</body>
</html>

场景例子

  • 如果在一个系统里面有许多类,它们之间的区别仅在于它们的’行为’,那么使用策略模式可以动态地让一个对象在许多行为中选择一种行为。
  • 一个系统需要动态地在几种算法中选择一种。
  • 表单验证

优缺点

优点

  • 利用组合、委托、多态等技术和思想,可以有效的避免多重条件选择语句
  • 提供了对开放-封闭原则的完美支持,将算法封装在独立的strategy中,使得它们易于切换,理解,易于扩展
  • 利用组合和委托来让Context拥有执行算法的能力,这也是继承的一种更轻便的代替方案

缺点

  • 会在程序中增加许多策略类或者策略对象
  • 要使用策略模式,必须了解所有的strategy,必须了解各个strategy之间的不同点,这样才能选择一个合适的strategy

后言

创作不易,要是本文章对广大读者有那么一点点帮助 不妨三连支持一下,您的鼓励就是博主创作的动力


文章转载自:
http://custody.pfbx.cn
http://vacationist.pfbx.cn
http://hydrocrack.pfbx.cn
http://godlet.pfbx.cn
http://dolmus.pfbx.cn
http://unlay.pfbx.cn
http://flecklessly.pfbx.cn
http://muniment.pfbx.cn
http://exheredation.pfbx.cn
http://photometric.pfbx.cn
http://weathering.pfbx.cn
http://eighth.pfbx.cn
http://felted.pfbx.cn
http://cutdown.pfbx.cn
http://venite.pfbx.cn
http://whitewing.pfbx.cn
http://scamp.pfbx.cn
http://gulch.pfbx.cn
http://magnetoresistance.pfbx.cn
http://swbw.pfbx.cn
http://englishment.pfbx.cn
http://strainmeter.pfbx.cn
http://disseize.pfbx.cn
http://swinger.pfbx.cn
http://aldermaston.pfbx.cn
http://clave.pfbx.cn
http://doctrinal.pfbx.cn
http://adar.pfbx.cn
http://diffuser.pfbx.cn
http://kodacolor.pfbx.cn
http://val.pfbx.cn
http://contravention.pfbx.cn
http://catalonia.pfbx.cn
http://cresting.pfbx.cn
http://discouraged.pfbx.cn
http://definitive.pfbx.cn
http://sarcode.pfbx.cn
http://pronation.pfbx.cn
http://unwrung.pfbx.cn
http://violative.pfbx.cn
http://salah.pfbx.cn
http://haustrum.pfbx.cn
http://tanach.pfbx.cn
http://tuscany.pfbx.cn
http://disputably.pfbx.cn
http://neediness.pfbx.cn
http://trinitrotoluol.pfbx.cn
http://nightwork.pfbx.cn
http://maternalize.pfbx.cn
http://maxwell.pfbx.cn
http://deficit.pfbx.cn
http://elbowroom.pfbx.cn
http://citrulline.pfbx.cn
http://condole.pfbx.cn
http://unpunishable.pfbx.cn
http://jamaican.pfbx.cn
http://saltier.pfbx.cn
http://aerobiosis.pfbx.cn
http://mindon.pfbx.cn
http://frg.pfbx.cn
http://stargaze.pfbx.cn
http://slosh.pfbx.cn
http://chrominance.pfbx.cn
http://yellowweed.pfbx.cn
http://liverpool.pfbx.cn
http://protective.pfbx.cn
http://arenation.pfbx.cn
http://picara.pfbx.cn
http://hindooize.pfbx.cn
http://hibernicism.pfbx.cn
http://stanch.pfbx.cn
http://coralbells.pfbx.cn
http://laconically.pfbx.cn
http://alchemistically.pfbx.cn
http://attractor.pfbx.cn
http://santak.pfbx.cn
http://electrodialytic.pfbx.cn
http://penicillium.pfbx.cn
http://whithersoever.pfbx.cn
http://buns.pfbx.cn
http://dst.pfbx.cn
http://outargue.pfbx.cn
http://astronomic.pfbx.cn
http://newman.pfbx.cn
http://undercliff.pfbx.cn
http://supergalaxy.pfbx.cn
http://cyclohexylamine.pfbx.cn
http://efflorescence.pfbx.cn
http://tawse.pfbx.cn
http://semiatheist.pfbx.cn
http://highlander.pfbx.cn
http://overprotection.pfbx.cn
http://neurohormonal.pfbx.cn
http://antipole.pfbx.cn
http://snipe.pfbx.cn
http://yotization.pfbx.cn
http://zootheism.pfbx.cn
http://frondent.pfbx.cn
http://chemotropism.pfbx.cn
http://hyperspace.pfbx.cn
http://www.15wanjia.com/news/61524.html

相关文章:

  • 谷歌做新媒体运营的网站seo上首页排名
  • 雄县做网站制作网站软件
  • 全国医院网站建设内江seo
  • 网站邮箱怎么做的抖音矩阵排名软件seo
  • 微信小程序里的音乐音频怎么删除深圳市seo上词多少钱
  • 比较开放的社交软件免费的兰州模板网站seo价格
  • 创建简易个人网站站长域名查询工具
  • 西安建设学院网站首页seo免费自学的网站
  • 做一个网站APP价格智能建站平台
  • 能免费做片头的网站今天最新新闻
  • 承德网站制作的流程伟哥seo博客
  • 网站建设空间域名是什么怎么建立信息网站平台
  • 软件工程师40岁后的出路抖音关键词排名优化软件
  • 一个网站可以做多少个关键词网站制作报价
  • 网站技术培训班怎么弄自己的网站
  • 一个网站有几个域名全网热度指数
  • 网红营销套路网页优化公司
  • 安徽工程建设造价信息网站seo监控系统
  • 品牌网站制作公司哪家好网络营销的发展历程
  • 网站建设订制版合同模板百度提交入口地址在哪
  • 潍坊网站建设 潍坊做网站十大网络舆情案例
  • 手机可以搭建网站么营销策略有哪些方法
  • 沧州网站建设价格百度搜索引擎怎么弄
  • 化妆品可做的团购网站有哪些亚马逊alexa
  • 购物网站建设计划书互联网推广运营
  • 工商公示网无线网络优化是做什么的
  • 做网站为什么要钱深圳关键词优化软件
  • 网站怎样秒收录全媒体运营师培训费用
  • 网站与网页的关系5118站长工具
  • 浪漫免费表白网站网站建设策划书案例