当前位置:网站首页>The detailed page returns to the list and retains the original position of the scroll bar
The detailed page returns to the list and retains the original position of the scroll bar
2022-07-06 00:37:00 【InfoQ】
meta
import 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
}]
keepAlive
keepAlive
<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: ' Journalism 1', desc: ' Journalism 1' },
{ id: 2, title: ' Journalism 2', desc: ' Journalism 2' },
{ id: 3, title: ' Journalism 3', desc: ' Journalism 3' },
{ id: 4, title: ' Journalism 4', desc: ' Journalism 4' },
{ id: 5, title: ' Journalism 5', desc: ' Journalism 5' },
{ id: 6, title: ' Journalism 6', desc: ' Journalism 6' },
{ id: 7, title: ' Journalism 7', desc: ' Journalism 7' },
{ id: 8, title: ' Journalism 8', desc: ' Journalism 8' },
{ id: 9, title: ' Journalism 9', desc: ' Journalism 9' },
{ id: 10, title: ' Journalism 10', desc: ' Journalism 10' },
{ id: 11, title: ' Journalism 11', desc: ' Journalism 11' },
{ id: 12, title: ' Journalism 12', desc: ' Journalism 12' },
{ id: 13, title: ' Journalism 13', desc: ' Journalism 13' },
{ id: 14, title: ' Journalism 14', desc: ' Journalism 14' },
{ id: 15, title: ' Journalism 15', desc: ' Journalism 15' }
]
}
},
beforeRouteLeave(to, from, next) {
console.log(' Activate beforeRouteLeave route ')
// }
this.scroll = this.$refs.listBox.scrollTop
console.log(this.scroll)
next()
},
activated() {
console.log(' Activate activated Hook function ')
this.$refs.listBox.scrollTop = this.scroll
}
}
</script>
beforeRouteLeave
activated
beforeRouteLeave
activated
边栏推荐
- Extracting profile data from profile measurement
- Natural language processing (NLP) - third party Library (Toolkit):allenlp [library for building various NLP models; based on pytorch]
- Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot system behavior analysis and project summary (4
- LeetCode 1189. Maximum number of "balloons"
- Set data real-time update during MDK debug
- LeetCode 6004. Get operands of 0
- Room cannot create an SQLite connection to verify the queries
- NLP basic task word segmentation third party Library: ICTCLAS [the third party library with the highest accuracy of Chinese word segmentation] [Chinese Academy of Sciences] [charge]
- Start from the bottom structure and learn the introduction of fpga---fifo IP core and its key parameters
- 《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network
猜你喜欢
XML Configuration File
About the slmgr command
关于slmgr命令的那些事
Key structure of ffmpeg - avformatcontext
FFT learning notes (I think it is detailed)
Key structure of ffmpeg - avframe
LeetCode 1189. Maximum number of "balloons"
Date类中日期转成指定字符串出现的问题及解决方法
How to solve the problems caused by the import process of ecology9.0
XML配置文件
随机推荐
Codeforces Round #804 (Div. 2)【比赛记录】
curlpost-php
Data analysis thinking analysis methods and business knowledge -- analysis methods (II)
【EI会议分享】2022年第三届智能制造与自动化前沿国际会议(CFIMA 2022)
从 1.5 开始搭建一个微服务框架——调用链追踪 traceId
STM32按键消抖——入门状态机思维
Browser reflow and redraw
图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
NLP generation model 2017: Why are those in transformer
The global and Chinese markets of dial indicator calipers 2022-2028: Research Report on technology, participants, trends, market size and share
Opencv classic 100 questions
Priority queue (heap)
2022-02-13 work record -- PHP parsing rich text
Go learning - dependency injection
[designmode] Decorator Pattern
What is information security? What is included? What is the difference with network security?
LeetCode 6004. Get operands of 0
Key structure of ffmpeg - avframe
常用API类及异常体系
Spark AQE