Skip to content

Toast重复触发onClose方法 #3319

Description

@heyq02

NutUI 包名

@nutui/nutui-taro, @nutui/nutui

NutUI 版本号

4.3.14

平台

h5

重现链接

https://nutui.jd.com/playground/#eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cCBsYW5nPVwidHNcIj5cbiAgaW1wb3J0IHsgcmVmIH0gZnJvbSBcInZ1ZVwiXG5pbXBvcnQgeyBzaG93VG9hc3QgfSBmcm9tICdAbnV0dWkvbnV0dWknXG5pbXBvcnQgeyBEb25nZG9uZyB9IGZyb20gJ0BudXR1aS9pY29ucy12dWUnXG4gIGNvbnN0IGNvdW50ID0gcmVmKDEpXG4gIFxuY29uc3Qgc2hvdyA9ICgpID0+IHtcbiAgc2hvd1RvYXN0LnRleHQoJ0hlbGxvLCBOdXRVSSEnLCB7XG4gICAgb25DbG9zZTogKCkgPT4ge1xuICAgICAgY291bnQudmFsdWUgPSBjb3VudC52YWx1ZSArIDFcbiAgICB9LFxuICAgIGNvdmVyOiB0cnVlLFxuICAgIGNsb3NlT25DbGlja092ZXJsYXk6IHRydWVcbiAgfSlcbiAgXG59O1xuPC9zY3JpcHQ+XG48dGVtcGxhdGU+XG4gIDxudXQtY2VsbCB0aXRsZT1cIkNsaWNrIHRvIHNob3cgVG9hc3RcIiBpcy1saW5rIEBjbGljaz1cInNob3dcIj5cbiAgICA8dGVtcGxhdGUgI2xpbms+XG4gICAgICA8RG9uZ2RvbmcgLz5cbiAgICA8L3RlbXBsYXRlPlxuICA8L251dC1jZWxsPlxuICA8ZGl2PlxuICAgIHt7Y291bnR9fVxuICA8L2Rpdj5cbjwvdGVtcGxhdGU+In0=

重现步骤

  1. 设置cover、closeOnClickOverlay和onClose
<script setup lang="ts">
const show = () => {
  showToast.text('Hello, NutUI!', {
    onClose: () => {
      count.value = count.value + 1
    },
    cover: true,
    closeOnClickOverlay: true
  })
  
};
  1. 点击按钮触发Toast提示
  2. 点击遮罩层触发关闭
  3. onClose执行两次
Image

期望的结果是什么?

onClose只触发一次

实际的结果是什么?

onClose触发两次

环境信息

System:
OS: macOS 15.7.4
CPU: (12) arm64 Apple M2 Pro
Memory: 177.50 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.14.0 - /Users/heyongqi10/.local/share/fnm/node-versions/v24.14.0/installation/bin/node
Yarn: 1.22.22 - /Users/heyongqi10/.local/share/fnm/node-versions/v24.14.0/installation/bin/yarn
npm: 11.9.0 - /Users/heyongqi10/.local/share/fnm/node-versions/v24.14.0/installation/bin/npm
pnpm: 10.32.1 - /Users/heyongqi10/.local/share/fnm/node-versions/v24.14.0/installation/bin/pnpm
Browsers:
Chrome: 146.0.7680.165
Safari: 26.3
npmPackages:
@nutui/nutui: ^4.3.14 => 4.3.14

其他补充信息

No response

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions