vue 初始行向滚到指定位置
2021-06-22 本文已影响0人
冷r
mounted() {
this.$nextTick(() => {
//滚动距离 获取滚动的元素(overflow:auto;overflow:scroll)
let scrollWidth = this.$refs['mcalendar'].scrollWidth
//根据星期滚动到当前日期
let week = new Date().getDay()
if (week === 0) week = 7
this.$refs['mcalendar'].scrollLeft = ((week - 1) / 7) * scrollWidth
})
},