更新页面

This commit is contained in:
2023-07-07 11:33:05 +08:00
parent 090136039e
commit 6ab7a22865
2 changed files with 40 additions and 26 deletions

View File

@@ -129,16 +129,17 @@ export default {
}, },
mounted() { mounted() {
window.addEventListener('scroll', this.onScroll);
window.addEventListener('scroll', this.scrollToTop);
this.initPage();
this.getMonely(); this.getMonely();
this.initPage();
this.FreshItems(); this.FreshItems();
// window.addEventListener('scroll',this.scrollToTop);
window.addEventListener('scroll',this.onScroll);
}, },
destroy() { destroy() {
// 必须移除监听器不然当该vue组件被销毁了监听器还在就会出错 // 必须移除监听器不然当该vue组件被销毁了监听器还在就会出错
window.removeEventListener('scroll', this.onScroll);
window.removeEventListener('scroll', this.scrollToTop); window.removeEventListener('scroll', this.scrollToTop);
window.removeEventListener('scroll', this.onScroll);
}, },
computed:{ computed:{
noMore() { noMore() {
@@ -156,27 +157,35 @@ export default {
}, },
methods: { methods: {
backTop () { backTop () {
const that = this let top = document.documentElement.scrollTop || document.body.scrollTop;
let timer = setInterval(() => { // 实现滚动效果
let ispeed = Math.floor(-that.scrollTop / 5) const timeTop = setInterval(() => {
document.documentElement.scrollTop = document.body.scrollTop = that.scrollTop + ispeed document.body.scrollTop = document.documentElement.scrollTop = top -= 50;
if (that.scrollTop === 0) { if (top <= 0) {
clearInterval(timer) clearInterval(timeTop);
} }
}, 16) }, 10);
},
// 为了计算距离顶部的高度当高度大于60显示回顶部图标小于60则隐藏 // const that = this
scrollToTop () { // let timer = setInterval(() => {
const that = this // let ispeed = Math.floor(-that.scrollTop / 5)
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop // document.documentElement.scrollTop = document.body.scrollTop = that.scrollTop + ispeed
that.scrollTop = scrollTop // if (that.scrollTop === 0) {
if (that.scrollTop > 60) { // clearInterval(timer)
that.btnFlag = true // }
} else { // }, 16)
that.btnFlag = false
}
}, },
// // 为了计算距离顶部的高度当高度大于60显示回顶部图标小于60则隐藏
// scrollToTop () {
// const that = this
// let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
// that.scrollTop = scrollTop
// if (that.scrollTop > 60) {
// that.btnFlag = true
// } else {
// that.btnFlag = false
// }
// },
//滚动 //滚动
// 点击切换锚点: // 点击切换锚点:
goAnchor(id) { goAnchor(id) {
@@ -265,6 +274,7 @@ export default {
that.MonType.push(key); that.MonType.push(key);
that.MonTypePro.push(that.MonList[key]); that.MonTypePro.push(that.MonList[key]);
}) })
console.log(that.MonList);
}) })
}, },
// 月刊详情页面跳转 // 月刊详情页面跳转

View File

@@ -3,10 +3,10 @@
<div style="display: flex;flex-direction:column;flex-wrap: nowrap"> <div style="display: flex;flex-direction:column;flex-wrap: nowrap">
<div class="PageHeader"> <div class="PageHeader">
<br/> <br/>
<el-page-header @back="goBack" style="justify-content: center;"> <el-page-header @back="goBack" style="justify-content:left;display: flex;">
<div slot="title" style="font-size:23px;font-weight: 600;"></div> <div slot="title" style="font-size:23px;font-weight: 600;"></div>
<div slot="content" style="font-size:23px;font-weight: 600;"> <div slot="content" class="test" style="font-size:23px;font-weight: 600;">
HelloGitHub (2023)年语言排行榜 <div>(2023)(1)季度语言排行榜</div>
</div> </div>
</el-page-header> </el-page-header>
</div> </div>
@@ -91,8 +91,12 @@ export default {
<style scoped lang="scss"> <style scoped lang="scss">
::v-deep .el-page-header__left{ ::v-deep .el-page-header__left{
left:-150px; left:10px;
} }
::v-deep .el-page-header__content{
flex:1;
}
.el-card{ .el-card{
border: none; border: none;
} }