Skip to content
This repository was archived by the owner on Oct 27, 2021. It is now read-only.

searchbar 的 onClear 事件不触发 #106

Closed
bug4j opened this issue Mar 12, 2021 · 3 comments
Closed

searchbar 的 onClear 事件不触发 #106

bug4j opened this issue Mar 12, 2021 · 3 comments

Comments

@bug4j
Copy link

bug4j commented Mar 12, 2021

问题描述
searchBar 绑定了 onChange事件和 onClear事件,点击 clear 图标 触发了onchange,但是没有触发onClear

复现步骤

  • template
<AtSearchBar :onChange="onSearchKeyChanged" onClear="onSearchClear" :value="searchKey" :onActionClick="onSearch"></AtSearchBar>
methods:{
 onSearchKeyChanged(val) { 
  console.log(val);
 },
  onSearchClear() {
    console.log('cleared');
  }
}

期望行为
正常触发clear事件

报错信息

系统信息

  • Taro 版本:0.0.7
  • Taro UI Vue 版本:1.0.0-beta.8
  • 报错平台:weapp

补充信息
看了下源码,AtSearchBar.ts 的 props 和 data 里面根本没有 onClear ,
但是在实际触发clear时,代码里面判断了有没有绑定onClear

handleClear(event: CommonEvent): void {
      if (this.onClear) {
        this.onClear(event);
      } else {
        this.onChange('', event)
      }
    },

所以这个bug就很没水平了

@psaren
Copy link
Owner

psaren commented Mar 12, 2021

请使用

:onClear=“onSearchClear”

不要使用

@clear=“onSearchClear”

@psaren psaren closed this as completed Mar 12, 2021
@bug4j
Copy link
Author

bug4j commented Mar 12, 2021

请使用

:onClear=“onSearchClear”

不要使用

@clear=“onSearchClear”

代码贴错了,使用

<AtSearchBar  onClear="onSearchClear" />

也无法触发对应的方法

1 similar comment
@bug4j
Copy link
Author

bug4j commented Mar 12, 2021

请使用

:onClear=“onSearchClear”

不要使用

@clear=“onSearchClear”

代码贴错了,使用

<AtSearchBar  onClear="onSearchClear" />

也无法触发对应的方法

psaren added a commit that referenced this issue Mar 16, 2021
psaren added a commit that referenced this issue Mar 16, 2021
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants