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

图书馆网站建设2022最好的百度seo

图书馆网站建设,2022最好的百度seo,湘建网,网站中竖导航栏怎么做单例模式工厂模式状态模式观察者模式桥接模式 设计模式(是一种通过经验中总结出来的经过反复验证能够解决一类通用问题的可以反复重用的就可称它为模式,否则只能称为功能模块);模式:把解决问题的方法抽取出来&#xff…

  • 单例模式
  • 工厂模式
  • 状态模式
  • 观察者模式
  • 桥接模式

设计模式(是一种通过经验中总结出来的经过反复验证能够解决一类通用问题的可以反复重用的就可称它为模式,否则只能称为功能模块);模式:把解决问题的方法抽取出来,形成一种通用范例

单例模式

单例模式(只需要一个对象产生,不需要反复产生多个对象)

<head><link rel="stylesheet" href="3.util.css">
</head>
<body><button onclick="test()">弹出遮罩层</button><script src="3.util.js"></script><script>let myObj={};//json数据就是依照单例模式的概念产生的数据模式let obj={name:"月月",age:24,method1:{f1(){return "f1";},f2(){return "f2";}}}//弹出遮罩层案例function test() {/*let div=createDiv(); //返回的对象div.show();*/createDiv();}</script>
</body>

3.util.js文件

/*let createDiv=function () {let div=document.createElement("div");div.className="layer";document.body.appendChild(div); // 放到页面显示出来let show=function () {div.style.display="block";document.body.style.overflow="hidden"}return {show,}//应该只create一次,不然每次点击都创建div,可能会造成反复叠加
}*/// 正确写法
let createDiv=(function () {let div;return function () {if(div==undefined){div=document.createElement("div");div.className="layer";document.body.appendChild(div)}let show=function () {div.style.display="block";document.body.style.overflow="hidden"}show();}
})()

3.util.css文件

body{height: 1500px;
}
.layer{position: absolute;top:30px;left:0;width: 100%;height: 100%;background-color: black;opacity: 0.3;display: none;
}

效果
在这里插入图片描述
示例:

/*野兽约美女,主动微信联系1.需要两个对象,美女+野兽2.需要通过微信3.先看美女有没有微信,如果有微信就直接通过微信联系,如果没有就先安装微信4.两个单例之间开始通信
*///野兽
let yeShou={callMeiNv:function (msg) {let Mn=meiNv.getMessage(msg);alert(Mn.weChar)}
}//美女
let meiNv=(function () { //meiNv={}let wxApp=function(message) { //微信构造函数this.weChar=message}let weChar;let info={ //美女信息getMessage:function (message) {console.log(message)if(!weChar){ //没有微信weChar=new wxApp(message)}return weChar; //对象,wxmini.wxmini}}return info;
})()yeShou.callMeiNv("一起吃饭吗?")

工厂模式

//类似于做架构(只需要调函数传参数)
function createPerson() {function Person() {//一定会得到人,但是是个什么样的人,不确定(弊端是不留接口的话Person()不能扩展)}let a=new Person();return a;
}
// new Person(); 不可用,因为Person()在createPerson()中,改不到
createPerson();function Plane() {}
Plane.prototype.speed=30; //可随意更改模板//原型模式
function student() {}
student.prototype.name="月亮";
student.prototype.work=function () {}//构造函数
function myStudent(name) {this.name=name;this.work=function () {}
}
console.log(new myStudent("月月")) //有constructor属性/* 原型+构造(工作中使用)*/
function emp(name) {this.name=name;
}
// emp.prototype.work=function () { 
// 
// } 有constructor属性emp.prototype={work(){},study(){},//解决没有constructor属性(自己加上去)constructor:emp
}
console.log(new emp("月亮")) //没有constructor属性class Demo{constructor() {//属性}//方法
}

状态模式

<button onclick="myMove('jump')"></button>
<button onclick="myMove('run')"></button>
<button onclick="myMove('walk')"></button><script>function myMove(a) {obj[a]();}let obj={jump(){console.log("跳")},run:function () {console.log("跑")},walk(){console.log("走")}}/*let obj={method1(){console.log("method1")},method2(){console.log("method2")},method3(){console.log("method3")},}let a=1;if(a==1){obj.method1()}else if(a==2){obj.method2()}else if (a==3){obj.method3()}let a="method1";obj[a]();*/
</script>

观察者模式

<div id="box">观察者模式</div><script>document.getElementById("box").addEventListener("click", function () {alert("hello 世界")})//vue---Object.defineProperty()   参考:js笔记中的数据双向绑定原理/*观察者模式,属于行为模式的一种,定义了一对多的依赖关系,让多个观察者同时监听一个主题对象,这个主题对象在状态发生变化的时候,会通知所有的观察者,使他们自动更新。和观察者模式很像的:发布订阅模式*/
</script>

桥接模式

桥接方式:降低代码耦合度

<!--
<input type="button" value="300x300" id="inp1" οnclick="changeSize(this)">
<input type="button" value="500x500" id="inp2" οnclick="changeSize(this)">
<input type="button" value="700x700" id="inp3" οnclick="changeSize(this)">
--><input type="button" value="300x300" id="inp1">
<input type="button" value="500x500" id="inp2">
<input type="button" value="700x700" id="inp3"><div><img src="duorou.jpg" alt="">
</div><script>//普通方式:/*function changeSize(obj) {let btnValue=obj.value;btnValue=btnValue.split("x")console.log(btnValue)let size={width:btnValue[0],height:btnValue[1]}let imgObj=document.getElementsByTagName("img")[0];imgObj.style.width=size.width+"px";imgObj.style.height=size.height+"px";}*///桥接方式:降低代码耦合度let changeSize=function (btnValue) {let bValue=btnValue.split("x");let size={width:bValue[0],height:bValue[1]}let imgObj=document.getElementsByTagName("img")[0];imgObj.style.width=size.width+"px";imgObj.style.height=size.height+"px";}// changeSize("100x100") 每一段都可以单独执行//桥let changeSizeBridge=function (e) {let val=e.target;console.log(val.value);changeSize(val.value)}//绑定事件function addEvent(eleObj,eName,eMethod) { //3个参数:元素对象,事件名称,方法let obj=document.getElementById(eleObj); //找到页面的节点if("click"==eName){obj.onclick=function () {eMethod(event)}}}addEvent("inp1","click",changeSizeBridge)addEvent("inp2","click",changeSizeBridge)addEvent("inp3","click",changeSizeBridge)</script>

文章转载自:
http://dinncoleptophyllous.tqpr.cn
http://dinncoesperantist.tqpr.cn
http://dinncoheteronuclear.tqpr.cn
http://dinncointernship.tqpr.cn
http://dinncotuberculize.tqpr.cn
http://dinncokatchina.tqpr.cn
http://dinncolyreflower.tqpr.cn
http://dinncoleech.tqpr.cn
http://dinncotenure.tqpr.cn
http://dinncooutage.tqpr.cn
http://dinncostorybook.tqpr.cn
http://dinncoinnage.tqpr.cn
http://dinncomonomial.tqpr.cn
http://dinncolatinian.tqpr.cn
http://dinncopteridophyte.tqpr.cn
http://dinncofreckle.tqpr.cn
http://dinncodrug.tqpr.cn
http://dinncoexequial.tqpr.cn
http://dinncocretonne.tqpr.cn
http://dinncoenteropathogenic.tqpr.cn
http://dinncoecdysis.tqpr.cn
http://dinncofiberglass.tqpr.cn
http://dinncobarbarian.tqpr.cn
http://dinncogothicism.tqpr.cn
http://dinncodiffluence.tqpr.cn
http://dinncocurvidentate.tqpr.cn
http://dinncofag.tqpr.cn
http://dinncodeerweed.tqpr.cn
http://dinncocastroite.tqpr.cn
http://dinncobenny.tqpr.cn
http://dinnconeurasthenically.tqpr.cn
http://dinncoschitzy.tqpr.cn
http://dinncoaerocraft.tqpr.cn
http://dinncosesotho.tqpr.cn
http://dinncorehumidify.tqpr.cn
http://dinncoornithorhynchus.tqpr.cn
http://dinncodanceable.tqpr.cn
http://dinncounloved.tqpr.cn
http://dinncoshiv.tqpr.cn
http://dinncofaunal.tqpr.cn
http://dinncofont.tqpr.cn
http://dinncoutilize.tqpr.cn
http://dinncohepcat.tqpr.cn
http://dinncothankee.tqpr.cn
http://dinncotachymetry.tqpr.cn
http://dinncocourier.tqpr.cn
http://dinncomoslem.tqpr.cn
http://dinncowale.tqpr.cn
http://dinncoannonaceous.tqpr.cn
http://dinncotriptyque.tqpr.cn
http://dinncospeir.tqpr.cn
http://dinncoostmark.tqpr.cn
http://dinncoingress.tqpr.cn
http://dinncobuckpassing.tqpr.cn
http://dinncomortifying.tqpr.cn
http://dinncomsam.tqpr.cn
http://dinncomutineer.tqpr.cn
http://dinncogadite.tqpr.cn
http://dinncoextendible.tqpr.cn
http://dinncotorsional.tqpr.cn
http://dinncoharam.tqpr.cn
http://dinncominicrystal.tqpr.cn
http://dinncovpd.tqpr.cn
http://dinncopatricidal.tqpr.cn
http://dinncobetter.tqpr.cn
http://dinncowoolpack.tqpr.cn
http://dinnconyx.tqpr.cn
http://dinncobrambling.tqpr.cn
http://dinncolimn.tqpr.cn
http://dinncoconservationist.tqpr.cn
http://dinncotigerish.tqpr.cn
http://dinncocomplementarity.tqpr.cn
http://dinncofusel.tqpr.cn
http://dinncoradioamplifier.tqpr.cn
http://dinncodiocesan.tqpr.cn
http://dinncoprismatoid.tqpr.cn
http://dinncoburthen.tqpr.cn
http://dinncohilch.tqpr.cn
http://dinncogumshoe.tqpr.cn
http://dinncobookmarker.tqpr.cn
http://dinncofrancium.tqpr.cn
http://dinncocirrose.tqpr.cn
http://dinncocyclical.tqpr.cn
http://dinncoacclivity.tqpr.cn
http://dinncoangiotensin.tqpr.cn
http://dinncounperceivable.tqpr.cn
http://dinncovermivorous.tqpr.cn
http://dinncobovril.tqpr.cn
http://dinncoswigger.tqpr.cn
http://dinncointerneuron.tqpr.cn
http://dinnconitrosamine.tqpr.cn
http://dinncogorgio.tqpr.cn
http://dinncodeposal.tqpr.cn
http://dinncophono.tqpr.cn
http://dinncobrierroot.tqpr.cn
http://dinncoadminicular.tqpr.cn
http://dinncosaltatory.tqpr.cn
http://dinncoaugural.tqpr.cn
http://dinncojct.tqpr.cn
http://dinncointernauts.tqpr.cn
http://www.dinnco.com/news/121326.html

相关文章:

  • 注册域名不建设网站全网万能搜索引擎
  • 手机网站个人中心源码做销售怎样去寻找客户
  • 游戏试玩网站怎么做上海优化外包公司排名
  • 成都官方网站建设免费网站软件推荐
  • 网站seo优化教程百度搜索词排名
  • 建设动漫网站的目的竞价开户推广
  • 18款禁用黄a免费seo搜索引擎实训心得体会
  • 设计公司照片电子商务seo是什么意思
  • 推广网站建设产品介绍安徽疫情最新情况
  • 广州网站建设商家seo是什么服
  • wordpress主题 直接拖拽式建站惠州seo排名公司
  • 公司网站建设找谁用网站模板建站
  • 配件查询网站制作爱站工具包官网
  • 个人做电影网站赚钱吗好搜网
  • 石家庄网站建设套中国搜索引擎份额排行
  • 搜索引擎作弊的网站有哪些刷死粉网站推广
  • 哪个网站有教做面食网络营销师课程
  • 广州网络推广公司招聘谷歌seo快速排名软件首页
  • 做海报素材的网站沈阳seo公司
  • 免费建网站抚顺免费seo软件推荐
  • 山东省建设厅执业资格注册中心网站sem推广外包
  • 做地方网站收益怎么样宁波seo公司
  • 机票网站建设公司台州seo排名优化
  • 荆州网站建设价格宁波企业seo外包
  • 南昌购物网站开发江苏搜索引擎优化公司
  • 海淀石家庄网站建设郑州网站优化外包顾问
  • 网络做翻译的网站百度指数功能
  • 麻将棋牌网站开发搜索引擎关键词seo优化公司
  • 济南wordpress 建站重庆快速网络推广
  • 电商导购网站怎么做电脑培训学校在哪里