diff --git a/example/pages/search/index.wxml b/example/pages/search/index.wxml
index 484015e3..4c60d927 100644
--- a/example/pages/search/index.wxml
+++ b/example/pages/search/index.wxml
@@ -1,18 +1,16 @@
@@ -30,14 +28,14 @@
搜索
diff --git a/packages/search/index.ts b/packages/search/index.ts
index 45f0ccb2..27f3c8cc 100644
--- a/packages/search/index.ts
+++ b/packages/search/index.ts
@@ -1,5 +1,6 @@
import { VantComponent } from '../common/component';
import { Weapp } from 'definitions/weapp';
+import { canIUseModel } from '../common/version';
VantComponent({
field: true,
@@ -48,7 +49,9 @@ VantComponent({
methods: {
onChange(event: Weapp.Event) {
- this.setData({ value: event.detail });
+ if (canIUseModel()) {
+ this.setData({ value: event.detail });
+ }
this.$emit('change', event.detail);
},
@@ -58,26 +61,28 @@ VantComponent({
* https://github.com/youzan/@vant/weapp/issues/1768
*/
setTimeout(() => {
- this.setData({ value: '' });
+ if (canIUseModel()) {
+ this.setData({ value: '' });
+ }
this.$emit('cancel');
this.$emit('change', '');
}, 200);
},
- onSearch() {
- this.$emit('search', this.data.value);
+ onSearch(event) {
+ this.$emit('search', event.detail);
},
- onFocus() {
- this.$emit('focus');
+ onFocus(event) {
+ this.$emit('focus', event.detail);
},
- onBlur() {
- this.$emit('blur');
+ onBlur(event) {
+ this.$emit('blur', event.detail);
},
- onClear() {
- this.$emit('clear');
+ onClear(event) {
+ this.$emit('clear', event.detail);
},
},
});
diff --git a/tsconfig.json b/tsconfig.json
index 1077c4e9..59460de4 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,7 +9,8 @@
"baseUrl": ".",
"types": ["miniprogram-api-typings"],
"paths": {
- "definitions/*": ["./packages/definitions/*"]
+ "definitions/*": ["./packages/definitions/*"],
+ "packages/*": ["./packages/*"]
},
"skipLibCheck": true
},