this.$refs['通过设置ref获取到的dom元素'].getBoundingClientRect();
//示例: 获取元素距离顶部的距离
this.$refs.journalUpward.getBoundingClientRect().top
// 获取组件高度
this.$refs.top.$el.offsetHeight
// 设置元素样式
this.$refs.mask.style.top = 100 + 'px'
本文介绍了如何在Vue.js中使用$refs属性来获取DOM元素及其相关信息,包括获取元素的位置、尺寸以及修改元素样式的方法。
this.$refs['通过设置ref获取到的dom元素'].getBoundingClientRect();
//示例: 获取元素距离顶部的距离
this.$refs.journalUpward.getBoundingClientRect().top
// 获取组件高度
this.$refs.top.$el.offsetHeight
// 设置元素样式
this.$refs.mask.style.top = 100 + 'px'
183

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