diff --git a/example/pages/search/index.js b/example/pages/search/index.js index 8d4fec15..bb7cf7a4 100644 --- a/example/pages/search/index.js +++ b/example/pages/search/index.js @@ -11,7 +11,16 @@ Page({ }); }, - onSearch(event) { + onSearch() { + if (this.data.value) { + wx.showToast({ + title: '搜索:' + this.data.value, + icon: 'none' + }); + } + }, + + onClick() { if (this.data.value) { wx.showToast({ title: '搜索:' + this.data.value, diff --git a/example/pages/search/index.wxml b/example/pages/search/index.wxml index 68c2bd96..089707fa 100644 --- a/example/pages/search/index.wxml +++ b/example/pages/search/index.wxml @@ -29,6 +29,6 @@ label="地址" shape="round" > - 搜索 + 搜索 diff --git a/packages/search/README.md b/packages/search/README.md index e03638d1..c4ede2f8 100644 --- a/packages/search/README.md +++ b/packages/search/README.md @@ -43,12 +43,35 @@ value="{{ value }}" placeholder="请输入搜索关键词" use-action-slot + bind:change="onChange" bind:search="onSearch" > - 搜索 + 搜索 ``` +```javascript +Page({ + data: { + value: '' + }, + + onChange(e) { + this.setData({ + value: e.detail + }); + }, + + onSearch() { + Toast('搜索' + this.data.value); + }, + + onClick() { + Toast('搜索' + this.data.value); + }, +}); +``` + ## API ### Props