当前位置:网站首页>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边栏推荐
- Yolov5, pychar, Anaconda environment installation
- CTF daily question day44 rot
- Browser reflow and redraw
- XML配置文件
- Uniapp development, packaged as H5 and deployed to the server
- synchronized 和 ReentrantLock
- Opencv classic 100 questions
- uniapp开发,打包成H5部署到服务器
- Free chat robot API
- Global and Chinese markets of universal milling machines 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
![Go learning --- structure to map[string]interface{}](/img/e3/59caa3f2ba5bd3647bdbba075ee60d.jpg)
Go learning --- structure to map[string]interface{}

Comment faire votre propre robot

MYSQL GROUP_ The concat function realizes the content merging of the same ID

Set data real-time update during MDK debug

Hudi of data Lake (2): Hudi compilation

Keepalive component cache does not take effect

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

建立时间和保持时间的模型分析
![[designmode] composite mode](/img/9a/25c7628595c6516ac34ba06121e8fa.png)
[designmode] composite mode
![[groovy] compile time meta programming (compile time method interception | method interception in myasttransformation visit method)](/img/e4/a41fe26efe389351780b322917d721.jpg)
[groovy] compile time meta programming (compile time method interception | method interception in myasttransformation visit method)
随机推荐
Ffmpeg learning - core module
图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
2022-02-13 work record -- PHP parsing rich text
Atcoder beginer contest 254 [VP record]
Keepalive component cache does not take effect
Atcoder beginer contest 258 [competition record]
从 1.5 开始搭建一个微服务框架——调用链追踪 traceId
MIT博士论文 | 使用神经符号学习的鲁棒可靠智能系统
Data analysis thinking analysis methods and business knowledge -- analysis methods (II)
Common API classes and exception systems
uniapp开发,打包成H5部署到服务器
Key structure of ffmpeg -- AVCodecContext
Pointer - character pointer
Date类中日期转成指定字符串出现的问题及解决方法
MySQL存储引擎
Global and Chinese market of digital serial inverter 2022-2028: Research Report on technology, participants, trends, market size and share
小程序技术优势与产业互联网相结合的分析
Room cannot create an SQLite connection to verify the queries
Browser reflow and redraw
Global and Chinese markets of universal milling machines 2022-2028: Research Report on technology, participants, trends, market size and share