实现功能:git
首先遇到的问题是作题区域与文章区域上下滑动的问题
怎样才能自适应屏幕呢github
首先在 created函数里,获取当前屏幕的高度浏览器
this.clientHeight = document.documentElement.clientHeight this.position = this.clientHeight / 2 this.positionEnd = this.clientHeight / 2
后来通过多方面调研,发现没有适合的分屏插件
因而决定本身写截屏插件网络
大致思路以下koa
代码以下yii
onPanup (e) { this.aniM = false console.log(this.clientHeight - this.position) if (this.clientHeight - this.position <= 200) { this.position = this.clientHeight - 200 this.contentHeight = this.position + 'px' return false } else { this.position = e.deltaY + this.positionEnd this.contentHeight = this.position + 'px' let child = document.getElementsByClassName('setHeight') if (this.examStatus) { for (var i = 0; i < child.length; i++) { child[i].setAttribute('style', 'padding-bottom:50px;height:' + (this.clientHeight - this.position - 100) + 'px') } } else { for (var j = 0; j < child.length; j++) { child[j].setAttribute('style', 'height:' + (this.clientHeight - this.position - 80) + 'px') } } } },
setH () { let child = document.getElementsByClassName('setHeight') if (this.examStatus) { for (var i = 0; i < child.length; i++) { child[i].setAttribute('style', 'padding-bottom:50px;height:' + (this.clientHeight - this.position - 100) + 'px') } } else { for (var j = 0; j < child.length; j++) { child[j].setAttribute('style', 'height:' + (this.clientHeight - this.position - 80) + 'px') } } },
onPanend (e) { if (this.clientHeight - this.position <= 200) { this.position = this.clientHeight - 201 this.positionEnd = this.clientHeight - 201 } else { this.positionEnd = this.positionEnd + e.deltaY } },
时间转换的函数
由秒转换XX:XX的格式函数
startTime () { this.startTimeTop ++ this.timeTrans(this.startTimeTop) setTimeout(() => { this.startTime() }, 1000) }, // 时间转换 timeTrans (val) { let f = parseInt(val / 60) let m = val % 60 if (f < 10) { f = '0' + f } if (m < 10) { m = '0' + m } this.time.f = f this.time.m = m },
测试网址点我跳转(手机打开或浏览器仿真)测试
github仓库地址git连接字体
https://github.com/fanshyiis/...
有用记得点个星
https://www.enjoyreading.net/...this
扫码也能够
上几张效果图