vue-scroller
vue-scroller copied to clipboard
vux中使用scrollTo 无效
使用vue-scroller 实现,列表->查看详细->返回列表具体位置。 使用了vuex keep alive 缓存了,列表的数据,在列表mounted中获取到之前的vue-scroller的位置,然后调用scrollTo 设置滚动到具体位置无效。请问这个问题大概出现在什么地方?什么状况下会影响scrollTo的执行效果?
在 生命周期deactivated中保存位置,在activated中调用
activated:function () {
let csp= this.$store.state.currScrollerPosition;
console.info(csp)
if(csp.length!=0){
setTimeout(() => {
this.$refs.kbList_scroller&&this.$refs.kbList_scroller.scrollTo(csp.left,csp.top,false);
}, 30)
}
},
deactivated:function () {
let currScrollerPosition=this.$refs.kbList_scroller.getPosition();//获取当前下拉的位置[]
this.$store.dispatch('SET_CURRSCROLLERPOSITION',currScrollerPosition);//设置当前滚动条的位置
console.info(currScrollerPosition);
},
问题解决了,加上setTimeout延时处理。