iframe嵌套页面没有办法获取浏览器滚动条,就监听嵌入页面DIV的滚动
<div id="app" @scroll="handleScroll">
<div>
methods:{
handleScroll(){
let appScroll = document.getElementById("app");
console.log(appScroll.scrollTop)
this.$store.commit('SETSCROLLTOP',appScroll.scrollTop)
}
本文介绍了一种解决iframe嵌套页面无法直接获取浏览器滚动条位置的方法,通过监听嵌入页面内部div元素的滚动事件来间接获取滚动条位置,并使用Vue.js的事件处理将滚动距离传递到store中。
iframe嵌套页面没有办法获取浏览器滚动条,就监听嵌入页面DIV的滚动
<div id="app" @scroll="handleScroll">
<div>
methods:{
handleScroll(){
let appScroll = document.getElementById("app");
console.log(appScroll.scrollTop)
this.$store.commit('SETSCROLLTOP',appScroll.scrollTop)
}
652
406

被折叠的 条评论
为什么被折叠?