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

加强图书馆网站建设广告优化师是做什么的

加强图书馆网站建设,广告优化师是做什么的,html网站设计实例代码,简述网页的制作流程今天菜鸟涨工资了,到手估计有8000左右了,有点开心,本来想上一篇就把这篇写了的,但是发现还是分开写比较好! 文章目录自适应js禁止放大播放声音store的使用websocket封装echarts实现渐变swiper常用的陌生方法&#xff0…

今天菜鸟涨工资了,到手估计有8000左右了,有点开心,本来想上一篇就把这篇写了的,但是发现还是分开写比较好!

文章目录

  • 自适应js
  • 禁止放大
  • 播放声音
  • store的使用
  • websocket封装
  • echarts实现渐变
  • swiper
  • 常用的陌生方法(只做记录,不介绍具体用法,持续更新)

自适应js

; (function (win) {var bodyStyle = document.createElement('style')bodyStyle.innerHTML = `body{width:1920px; height:1200px}`  // 需要适配的屏幕的宽高document.documentElement.firstElementChild.appendChild(bodyStyle)function refreshScale() {let docWidth = document.documentElement.clientWidthlet docHeight = document.documentElement.clientHeightvar designWidth = 1920 // 需要适配的屏幕的宽var designHeight = 1200  // 需要适配的屏幕的高var widthRatio = 0widthRatio = docWidth / designWidthvar heightRatio = 0heightRatio = docHeight / designHeightdocument.body.style ='transform:scale(' +widthRatio +',' +heightRatio +');transform-origin:left top;'// 应对浏览器全屏切换前后窗口因短暂滚动条问题出现未占满情况setTimeout(function () {var lateWidth = document.documentElement.clientWidth,lateHeight = document.documentElement.clientHeightif (lateWidth === docWidth) returnwidthRatio = lateWidth / designWidthheightRatio = lateHeight / designHeightdocument.body.style ='transform:scale(' +widthRatio +',' +heightRatio +');transform-origin:left top;'}, 0)}refreshScale()window.addEventListener('pageshow',function (e) {if (e.persisted) {// 浏览器后退的时候重新计算refreshScale()}},false)window.addEventListener('resize', refreshScale, false)
})(window);

这个自适应是最简单的自适应,主要用来对一些等比例的屏幕或者长宽比相近的屏幕的适配,主要还是针对类似电脑屏幕的适配!

注意:
1、如果项目有3d相关的操作,那么这个可能会适得其反,让本来百分比就可以适配的变得不适配!参考:swiper 3d 结合 loop 向左移动缺少一个内容

2、手机端、pad端还是建议使用px2rem,参考我的:使用px2rem不生效

禁止放大

// 禁用双指放大
document.documentElement.addEventListener('touchstart',function (event) {if (event.touches.length > 1) {event.preventDefault()}},{passive: false,}
);// 禁用双击放大
var lastTouchEnd = 0
document.documentElement.addEventListener('touchend',function (event) {var now = Date.now()if (now - lastTouchEnd <= 300) {event.preventDefault()}lastTouchEnd = now},{passive: false}
)

播放声音

// 添加音频
const audiodom = document.createElement("audio");
audiodom.setAttribute("id", "callmusic");
audiodom.setAttribute("loop", "loop");
audiodom.setAttribute("src", "static/audio/game_start.mp3");
document.body.appendChild(audiodom);
const callmusic = document.getElementById("callmusic");
callmusic.play();// 移除音频
const callmusic = document.getElementById("callmusic");
document.body.removeChild(callmusic);

注意:
1、如果一个界面有好几个音频,一定要取不同的名字!
2、如果是组件里面有音频,而组件会复用,那么一定要动态绑定id!
eg:

audiodom.setAttribute("id", "callmusic"+this.id)  // id由父组件传入

store的使用

store在项目中真的很容易使用到,但是每个界面都用什么this.$sotre.xxx的真的很麻烦,所以一定要记得这几个方法:

import {mapState, mapMutations, mapGetters} from "vuex";

每一个的使用:

在这里插入图片描述
在这里插入图片描述

websocket封装

websocket确实使用起来很简单,但是最好搞一个统一的断线重连以及连接流程,不然真的不太好规范!

这里菜鸟把公司一个同事的封装的献上:

data:

// 连接地址
websocketUrlPlay: xxxxxx,
// 断线重连
lockReconnect: false,
// 重连定时器
reconnetTimer: null

method:

// 重连
reconnect() {if (this.lockReconnect) {return;}this.lockReconnect = true;// 没连接上会一直重连,设置延迟避免请求过多this.reconnetTimer && clearTimeout(this.reconnetTimer);this.reconnetTimer = setTimeout(() => {this.createWebsocketPlay();this.lockReconnect = false;}, 4000);
},// 创建websocket
createWebsocketPlay() {// eslint-disable-next-linethis.socket = new WebSocket(this.websocketUrlPlay);this.socket.onopen = () => {// onopen 连接触发console.log("websocket pad open");};this.socket.onclose = () => {// onclose 断开触发console.log("websocket close");this.reconnect();};this.socket.onerror = () => {console.log("发生异常了");this.reconnect();};this.socket.onmessage = (event) => {// console.log(JSON.parse(event.data));const data = JSON.parse(event.data);}
}

注意:

1、这个 lockReconnect 类似于java中的 锁,所以 断开连接的时候一定要置为true

this.lockReconnect = true;
clearTimeout(this.reconnetTimer);
this.reconnetTimer = null;setTimeout(()=>{this.socket.close();
},100);  // 建议关闭时延时,可以更加有效!

echarts实现渐变

itemStyle: {color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: "#17e5a2" },{ offset: 1, color: "#23e8ca" },]),
},

swiper

1、swiper数据变化后,重新渲染

this.$nextTick(()=>{this.mySwiper.update();
})

常用的陌生方法(只做记录,不介绍具体用法,持续更新)

1、findIndex
2、some
3、

http://www.15wanjia.com/news/48502.html

相关文章:

  • 南昌网站建设培训学校济南百度竞价代运营
  • 网络 网站自己怎么做百度推广
  • 淘客商品网站怎么做的百度识图扫一扫入口
  • 制造行业网站建设今日热搜榜排行榜
  • 学校网站建设需要多少钱产品推广方案范例
  • 网站为什么需要空间淘宝网店的seo主要是什么
  • 外贸公司英文网站怎么做微信推广广告在哪里做
  • 一般政府网站用什么做湖人排名最新
  • 景德镇做网站中山seo推广优化
  • 怎么用vs2008做网站惠州自动seo
  • 临沂网站建设电话1688精品货源网站入口
  • 长沙营销型网站开发seo高效优化
  • 园林景观设计公司及高校人才培养建议廊坊网站seo
  • 网站注册人查询万能的搜索引擎
  • 网站备案需要多长时间青岛网站推广关键词
  • 网站首页设计代码收录是什么意思
  • 申请阿里巴巴网站首页企业营销策划有限公司
  • 网站开发后台需要哪些技术怎么制作百度网页
  • 过年做那个网站致富app投放渠道有哪些
  • app网站开发哪里有关键词搜索引擎工具爱站
  • 做网站挣钱打擦边球sem对seo的影响有哪些
  • 11108给换成119333做网站中国十大营销策划机构
  • 国外 网页框架搭建的网站外链平台
  • wordpress更改域名修改站内链接企业网站运营推广
  • 泰安网站制作工作室南昌seo
  • 哈尔滨大型网站建设电话利尔化学股票最新消息
  • 荆州松滋网站建设情感营销案例
  • WordPress中文标题不显示百度seo培训课程
  • asp企业网站自助建站系统免费版超漂亮版关键词搜索趋势
  • 网站建设微信运营公司企业网站优化推广