vue-drag-resize
vue-drag-resize copied to clipboard
请问什么条件下,才是激活的状态?
场景如下: 1.设置:isActive="true",然后点击其他地方,这个时候,并没有把isActive给设置为false,为了业务需求,那么,当我再次回到这边的时候,拖动却无法响应,一定要点击一次,然后才可以拖动
是的,我现在的项目也遇到了你的问题。请问你解决了吗
我使用的是传值,不能直接定义为true,当点击其他地方设置false,点回来在设置为true,这样点回来就可以拖动。
我也遇到了这个问题,大家是怎么解决的呀
我使用的是传值,不能直接定义为true,当点击其他地方设置false,点回来在设置为true,这样点回来就可以拖动。
按这个思路实现了一下
mounted() {
document.addEventListener("click", this.refreshActive)
},
beforeDestroy() {
document.removeEventListener("click", this.refreshActive)
},
methods: {
// reset active
refreshActive(e) {
const activeEls = this.$el.querySelectorAll(".vdr.active")
if (!activeEls.length || Array.from(activeEls).some((el) => el.contains(e.target))) return
this.isActive = false
this.$nextTick(() => {
this.isActive = true
})
},
}