ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

slider组件的afterChange会触发两次

Open L-ZJoker opened this issue 1 year ago • 2 comments
trafficstars

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Version

4.2.3

Environment

官网示例, chrome 126.0.6478.61

Reproduction link

https://next.antdv.com/components/slider-cn#components-slider-demo-event

Steps to reproduce

点击slider,再点击页面任何位置。

What is expected?

改变slider的值,afterChange事件只触发一次。

What is actually happening?

点击slider改变值之后会触发一次afterChange事件,此时在点击页面任何位置会再次触发该事件。控制台会有两次关于afterChange的输出。 image

L-ZJoker avatar Jun 28 '24 06:06 L-ZJoker

我的做法是 change事件设置标志位 after-change 触发事件

 <a-slider
  v-model:value="value"
  @afterChange="onChange"
  @change="
    () => {
      flag = true
    }
  " />

<script>
let flag = false
function onChange() {
  if (flag ) {
    nextTick(() => {
      // TODO
    })
    flag = false
  }
}
</script>

junfalin avatar Aug 15 '24 01:08 junfalin

same issue encountered. seems like a bug. but above workaround seems fine.

whsasf avatar Aug 26 '24 04:08 whsasf

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Oct 28 '24 02:10 github-actions[bot]