当前位置:网站首页>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】
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: ' 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>beforeRouteLeaveactivatedbeforeRouteLeaveactivated边栏推荐
- Idea远程提交spark任务到yarn集群
- FFT learning notes (I think it is detailed)
- LeetCode 6005. The minimum operand to make an array an alternating array
- XML配置文件
- 时间戳的拓展及应用实例
- Folding and sinking sand -- weekly record of ETF
- Spark SQL UDF function
- For a deadline, the IT fellow graduated from Tsinghua suddenly died on the toilet
- Promise
- Browser local storage
猜你喜欢

Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed

Basic introduction and source code analysis of webrtc threads

2022-02-13 work record -- PHP parsing rich text

如何制作自己的机器人

Classic CTF topic about FTP protocol

Hudi of data Lake (1): introduction to Hudi
![[groovy] JSON serialization (jsonbuilder builder | generates JSON string with root node name | generates JSON string without root node name)](/img/dd/bffe27b04d830d70f30df95a82b3d2.jpg)
[groovy] JSON serialization (jsonbuilder builder | generates JSON string with root node name | generates JSON string without root node name)

如何利用Flutter框架开发运行小程序
![Go learning --- structure to map[string]interface{}](/img/e3/59caa3f2ba5bd3647bdbba075ee60d.jpg)
Go learning --- structure to map[string]interface{}

数据分析思维分析方法和业务知识——分析方法(三)
随机推荐
[designmode] adapter pattern
Natural language processing (NLP) - third party Library (Toolkit):allenlp [library for building various NLP models; based on pytorch]
Analysis of the combination of small program technology advantages and industrial Internet
How to solve the problems caused by the import process of ecology9.0
State mode design procedure: Heroes in the game can rest, defend, attack normally and attack skills according to different physical strength values.
LeetCode 6006. Take out the least number of magic beans
Spark AQE
Pointer - character pointer
FPGA内部硬件结构与代码的关系
About the slmgr command
The relationship between FPGA internal hardware structure and code
[groovy] XML serialization (use markupbuilder to generate XML data | set XML tag content | set XML tag attributes)
Ffmpeg learning - core module
[simple implementation of file IO]
[designmode] composite mode
[designmode] Decorator Pattern
Recognize the small experiment of extracting and displaying Mel spectrum (observe the difference between different y_axis and x_axis)
STM32 key chattering elimination - entry state machine thinking
Comment faire votre propre robot
FFmpeg抓取RTSP图像进行图像分析