当前位置:网站首页>详细页返回列表保留原来滚动条所在位置
详细页返回列表保留原来滚动条所在位置
2022-07-06 00:33:00 【InfoQ】
metaimport Vue from 'vue'
import VueRouter from 'vue-router'
import News from '../views/News'
import New from '../components/new'
Vue.use(VueRouter)
const routes = [{
path: '/',
component: News,
meta: { keepAlive: true }
}, {
path: '/new/:id',
component: New
}]
keepAlivekeepAlive<template>
<div id="app">
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
</div>
</template>keepAlive<template>
<div id="news" ref="listBox">
<ul>
<li v-for=" newa in news" :key="newa.id">
<router-link :to="'/new/' +newa.id">{{newa.title}}</router-link>
</li>
</ul>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'news',
data() {
return {
scroll: 0,
news: [
{ id: 1, title: '新闻1', desc: '新闻1' },
{ id: 2, title: '新闻2', desc: '新闻2' },
{ id: 3, title: '新闻3', desc: '新闻3' },
{ id: 4, title: '新闻4', desc: '新闻4' },
{ id: 5, title: '新闻5', desc: '新闻5' },
{ id: 6, title: '新闻6', desc: '新闻6' },
{ id: 7, title: '新闻7', desc: '新闻7' },
{ id: 8, title: '新闻8', desc: '新闻8' },
{ id: 9, title: '新闻9', desc: '新闻9' },
{ id: 10, title: '新闻10', desc: '新闻10' },
{ id: 11, title: '新闻11', desc: '新闻11' },
{ id: 12, title: '新闻12', desc: '新闻12' },
{ id: 13, title: '新闻13', desc: '新闻13' },
{ id: 14, title: '新闻14', desc: '新闻14' },
{ id: 15, title: '新闻15', desc: '新闻15' }
]
}
},
beforeRouteLeave(to, from, next) {
console.log('激活beforeRouteLeave路由')
// }
this.scroll = this.$refs.listBox.scrollTop
console.log(this.scroll)
next()
},
activated() {
console.log('激活activated钩子函数')
this.$refs.listBox.scrollTop = this.scroll
}
}
</script>beforeRouteLeaveactivatedbeforeRouteLeaveactivated边栏推荐
- 如何解决ecology9.0执行导入流程流程产生的问题
- The global and Chinese markets of dial indicator calipers 2022-2028: Research Report on technology, participants, trends, market size and share
- Solve the problem of reading Chinese garbled code in sqlserver connection database
- Codeforces round 804 (Div. 2) [competition record]
- Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed
- Atcoder beginer contest 258 [competition record]
- Choose to pay tribute to the spirit behind continuous struggle -- Dialogue will values [Issue 4]
- Free chat robot API
- Key structure of ffmpeg -- AVCodecContext
- Leetcode 450 deleting nodes in a binary search tree
猜你喜欢
![N1 # if you work on a metauniverse product [metauniverse · interdisciplinary] Season 2 S2](/img/f3/8e237296f5948dd0488441aa625182.jpg)
N1 # if you work on a metauniverse product [metauniverse · interdisciplinary] Season 2 S2

Permission problem: source bash_ profile permission denied

Data analysis thinking analysis methods and business knowledge - analysis methods (III)

Free chat robot API

Key structure of ffmpeg -- AVCodecContext

Arduino六足机器人

wx. Getlocation (object object) application method, latest version

Leetcode:20220213 week race (less bugs, top 10% 555)

FFmpeg抓取RTSP图像进行图像分析

Configuring OSPF load sharing for Huawei devices
随机推荐
[Chongqing Guangdong education] reference materials for Zhengzhou Vocational College of finance, taxation and finance to play around the E-era
DEJA_ Vu3d - cesium feature set 055 - summary description of map service addresses of domestic and foreign manufacturers
Global and Chinese market of valve institutions 2022-2028: Research Report on technology, participants, trends, market size and share
Power query data format conversion, Split Merge extraction, delete duplicates, delete errors, transpose and reverse, perspective and reverse perspective
Spark DF adds a column
What is information security? What is included? What is the difference with network security?
如何制作自己的机器人
Tools to improve work efficiency: the idea of SQL batch generation tools
FFT learning notes (I think it is detailed)
notepad++正則錶達式替換字符串
Priority queue (heap)
How to use the flutter framework to develop and run small programs
Ffmpeg captures RTSP images for image analysis
Meta AI西雅图研究负责人Luke Zettlemoyer | 万亿参数后,大模型会持续增长吗?
Codeforces round 804 (Div. 2) [competition record]
AtCoder Beginner Contest 258【比赛记录】
Global and Chinese market of water heater expansion tank 2022-2028: Research Report on technology, participants, trends, market size and share
Data analysis thinking analysis methods and business knowledge -- analysis methods (II)
[EI conference sharing] the Third International Conference on intelligent manufacturing and automation frontier in 2022 (cfima 2022)
[Chongqing Guangdong education] Chongqing Engineering Vocational and Technical College