
在vue项目中,只说明宽度,高度不做补充
offsetWidth = 元素宽度 + padding + border
clientWidth = 元素宽度 + padding
scrollWidth = 元素宽度 + padding + 溢出尺寸,无溢出 = clientWidth
(1)如果你元素有内联样式style=“width:100px;height:100px;”
获取宽 this.$refs.名称.style.width,返回值:字符串且带单位
设置宽 this.$refs.名称.style.width = "这里一定要带单位"
(2)如果你元素没有内联样式或者宽高是写在class标签内的
获取宽:this.$refs.名称.offsetWidth,返回值:无单位
设置宽this.$refs.名称.称.offsetWidth = number + ‘px’
2334



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



