今天在做电影app时,需求是:有一个长列表,当我们滑动后,进入了另外一个页面之后在返回列表页时,会依旧保持我们第一次滑动的位置。看图:
解决方法:
在router.js(由于配置不同,或许有些人需写在router/index.js)中写入以下代码:
import Router from 'vue-router';
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}