Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input-number组件绑定ref值,改变步数会不停触发watch #3395

Open
1 task
Alcantara6 opened this issue Dec 18, 2020 · 2 comments
Open
1 task

input-number组件绑定ref值,改变步数会不停触发watch #3395

Alcantara6 opened this issue Dec 18, 2020 · 2 comments

Comments

@Alcantara6
Copy link

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

Version

2.0.0-rc.4

Environment

Win10, Chrome 84.0.4147.105, vue3.0.4

Reproduction link

https://2x.antdv.com/components/input-number-cn/

Steps to reproduce

<a-input-number v-model:value="count" title="数字输入" @change="onChange"></a-input-number>
export default defineComponent({
setup() {
    const count = ref(0);

    watch(count, val => {
        debugger;  // 点击数字输入框的上下箭头,会不停触发断点。直接输入数值不会。
        console.log(val);
    });

    const onChange = val => {
        debugger;  // 也会不停触发断点
        console.log(val);
    };

    return {
        count,
        onChange
    };
  }
})

What is expected?

点击数字输入框的上下箭头,触发一次断点,打印新值

What is actually happening?

点击数字输入框的上下箭头,不停触发断点,打印新值


如果使用computeds的set绑定count,以及a-input-number的change事件也一样

@tangjinzhou
Copy link
Member

为了兼容 移动端的 长按 一直增加数字的 效果,内部使用了 settimeout,在change 中打断点,会导致不能停止该延迟器

暂无比较好的方法,先不要在 onchange 里打断点就可以了

@Alcantara6
Copy link
Author

Alcantara6 commented Jan 16, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants