mounted () {
window.addEventListener('scroll', this.fixedActiveBtn, true)
},
data () {
return {
fixed: false
}
},
fixedActiveBtn (e) {
var scrollTop = e.target.scrollTop
if (e.target.getAttribute('class') === 'el-main') {
scrollTop >= 140 ? this.fixed = true : this.fixed = false
}
}
<div :class="fixed ? 'phoneBoxfixed':''"></div>
.phoneBoxfixed{
position: fixed !important;
}
.phoneBox{
position: absolute;
right: 40px;
top: 100px;
width: 400px;
height: 750px;
}