getBoundingClientRect() 返回的位置信息有很大概率存在多位的小数,影响用户体验
mishe opened this issue · 1 comments
mishe commented
handleDrop(e) {
e.preventDefault()
e.stopPropagation()
const index = e.dataTransfer.getData('index')
const rectInfo = this.editor.getBoundingClientRect()
// console.log(rectInfo)
if (index) {
const component = deepCopy(componentList[index])
component.style.top = e.clientY - Math.floor(rectInfo.y)
component.style.left = e.clientX - Math.floor(rectInfo.x)
component.id = generateID()
this.$store.commit('addComponent', { component })
this.$store.commit('recordSnapshot')
}
}
建议增加加粗代码