Ios 10.2.1 Vue project setting scrollTo(0,0) failure problem and solution
ScrollTo and scrollTop
So if I scroll to the top here’s what I started with
<template> <div id='container' ref= 'container'> .... <div class=' BTN '@click='scrollToTop'> Scroll to the top </div> </div> </template> <script> export default{data(){return{}}, Methods (){scrollToTop(){this.$refs.container.scrollto (0,0)}}} </script>Copy the code
$refs.container. ScrollTo is undefined. This.$refs.container. But there is a scrollTop property! Decision plus judgment
If (this.$refs.container. ScrollTo){this.$refs.container. ScrollTo (0,0)}else{this.$refs.container.Copy the code