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

服务器放多个网站网页设计与制作期末作业源代码

服务器放多个网站,网页设计与制作期末作业源代码,珠宝首饰网站源码,网站开发的企业桥接模式 通过桥接模式#xff0c;我们可以将业务逻辑与元素的事件解耦#xff0c;也可以更灵活的创建一些对象 倘若我们有如下代码 const dom document.getElementById(#test)// 鼠标移入移出事件 // 鼠标移入时改变背景色和字体颜色 dom.onmouseenter function() { th…桥接模式 通过桥接模式我们可以将业务逻辑与元素的事件解耦也可以更灵活的创建一些对象 倘若我们有如下代码 const dom document.getElementById(#test)// 鼠标移入移出事件 // 鼠标移入时改变背景色和字体颜色 dom.onmouseenter function() { this.style.color whitethis.style.backgroundColor black }// 鼠标移出时恢复背景色和字体颜色 dom.onmouseleave function () {this.style.color blackthis.style.backgroundColor white }这里我们不难看出有部分代码是重复的只是改变了字体颜色跟背景色这耦合度就高起来了我们可以是这样 const changeColor (dom, color, val){dom.style[color] val } const dom document.getElementById(#test) dom.onmouseenter function () {changeColor(this, color, white)changeColor(this, backgroundColor, black) } dom.onmouseleave function () {changeColor(this, color, black)changeColor(this, backgroundColor, white) } 继续优化 const changeColor (dom, color, val){dom.style[color] val } const changeColorAndBgColor (dom, color, bgColor){changeColor(dom, color, color)changeColor(dom, backgroundColor, bgColor) } const dom document.getElementById(#test) dom.onmouseenter function () {changeColorAndBgColor(this, white, black) } dom.onmouseleave function () {changeColor(this, black, white) } 多元化 在使用不同角色有相同公用的方法时可以使用这种多元化来处理 const Speed (x, y) {this.x xthis.y y } Speed.prototype.run function () { console.log(first run) } // TODO其他内容 const Color color {this.color color } Color.prototype.draw function () {console.log(first draw) } // TODO其他内容 const Speak word {this.word word } Speak.prototype.say function () {console.log(first say) } // TODO其他内容// 创建一个 球 const Ball function (x, y, color) {this.speed new Speed(x, y)this.color new Color(color) } Ball.prototype.init function () {this.speed.run()this.color.draw() }// 创建一个人 const People function (x, y, say) {this.speed new Speed(x, y)this.speak new Speak(say) } People.prototype.init function () {this.speed.run()this.speak.say() } ... 通过桥接灵活的创建一个对象针对不同的对象处理不同的业务逻辑更灵活处理差异
http://www.dnsts.com.cn/news/78901.html

相关文章:

  • 网站开发充值功能可信的手机网站建设
  • 免费的行情软件网站不用下载陕西城乡住房建设部网站
  • 做百度网站好吗建设电影网站需要什么
  • 晋中市科技馆网站建设wordpress钩子大全
  • wordpress收费么企业网站seo排名优化
  • 山东网站制作公司排名怎么在百度搜索到我的网站
  • 温州企业建站程序辛集seo网站优化
  • 晋江论坛网站网站建设工作推进会上的讲话
  • 网页作业班级网站怎么做局域网网站建设软件
  • 门户网站设计技巧网站开发的学习方法
  • 自己做盗号网站徐州网站建设开发
  • 应用网站如何做做便宜的宝贝的网站
  • 免费招聘网站推荐深圳网站优化最好的方法
  • 网站建设招标技术要求公司网页设计思路
  • 惠州 网站建设做网站的要到处跑吗
  • 新网站没有死链接怎么做网站推广文章 优帮云
  • 广东网站建设专业公司排名wordpress 主页文件
  • 网站后台更新了 前台不现实小果seo实战培训课程
  • 做网站的图片房产it设备网站如何做seo
  • 帮人管理网站做淘宝客广州优化防控措施
  • 网站如何加速WordPress 云解析视频
  • 自己可以做网站网址导航网站
  • 最新的电商平台网站优化外包服务
  • 用git 做网站做网站配什么绿色好看些
  • 模块网站和定制网站区别做一个答疑网站
  • 南宁在哪里推广网站张家港网站设计制作早晨设计
  • 遨游网站建设如何帮人做网站赚钱
  • 佛山市外贸网站建设微信公众平台小程序在哪
  • 宁波网站seo诊断工具上海人力资源网官方网
  • 搜索网站 模板各大网站流量排名