feat(search): support model value

This commit is contained in:
rex 2020-05-01 22:25:44 +08:00
parent f2c4c02a37
commit f9b53aad99
2 changed files with 17 additions and 11 deletions

View File

@ -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);
},
},
});

View File

@ -9,7 +9,8 @@
"baseUrl": ".",
"types": ["miniprogram-api-typings"],
"paths": {
"definitions/*": ["./packages/definitions/*"]
"definitions/*": ["./packages/definitions/*"],
"packages/*": ["./packages/*"]
},
"skipLibCheck": true
},