mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(search): support model value
This commit is contained in:
parent
f2c4c02a37
commit
f9b53aad99
@ -1,5 +1,6 @@
|
|||||||
import { VantComponent } from '../common/component';
|
import { VantComponent } from '../common/component';
|
||||||
import { Weapp } from 'definitions/weapp';
|
import { Weapp } from 'definitions/weapp';
|
||||||
|
import { canIUseModel } from '../common/version';
|
||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
field: true,
|
field: true,
|
||||||
@ -48,7 +49,9 @@ VantComponent({
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onChange(event: Weapp.Event) {
|
onChange(event: Weapp.Event) {
|
||||||
this.setData({ value: event.detail });
|
if (canIUseModel()) {
|
||||||
|
this.setData({ value: event.detail });
|
||||||
|
}
|
||||||
this.$emit('change', event.detail);
|
this.$emit('change', event.detail);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -58,26 +61,28 @@ VantComponent({
|
|||||||
* https://github.com/youzan/@vant/weapp/issues/1768
|
* https://github.com/youzan/@vant/weapp/issues/1768
|
||||||
*/
|
*/
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.setData({ value: '' });
|
if (canIUseModel()) {
|
||||||
|
this.setData({ value: '' });
|
||||||
|
}
|
||||||
this.$emit('cancel');
|
this.$emit('cancel');
|
||||||
this.$emit('change', '');
|
this.$emit('change', '');
|
||||||
}, 200);
|
}, 200);
|
||||||
},
|
},
|
||||||
|
|
||||||
onSearch() {
|
onSearch(event) {
|
||||||
this.$emit('search', this.data.value);
|
this.$emit('search', event.detail);
|
||||||
},
|
},
|
||||||
|
|
||||||
onFocus() {
|
onFocus(event) {
|
||||||
this.$emit('focus');
|
this.$emit('focus', event.detail);
|
||||||
},
|
},
|
||||||
|
|
||||||
onBlur() {
|
onBlur(event) {
|
||||||
this.$emit('blur');
|
this.$emit('blur', event.detail);
|
||||||
},
|
},
|
||||||
|
|
||||||
onClear() {
|
onClear(event) {
|
||||||
this.$emit('clear');
|
this.$emit('clear', event.detail);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"types": ["miniprogram-api-typings"],
|
"types": ["miniprogram-api-typings"],
|
||||||
"paths": {
|
"paths": {
|
||||||
"definitions/*": ["./packages/definitions/*"]
|
"definitions/*": ["./packages/definitions/*"],
|
||||||
|
"packages/*": ["./packages/*"]
|
||||||
},
|
},
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user