//寻找父元素的ref (组件形式)
this.$parent.$refs.xxx.scrollTo({
top: height,//滚动高度
behavior: 'smooth' // 平滑滚动
})
首先下载插件
npm install smoothscroll-polyfill --save
然后引入并在组件创建的时候调用下这个方法:比如mounted中
import smoothscroll from 'smoothscroll-polyfill'
mounted() {
// 解决移动端 scrollTo 的 behavior: "smooth" 无效的问题
smoothscroll.polyfill()
}