mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Search): add blur method
This commit is contained in:
parent
2833bc03f5
commit
d26282e542
@ -148,6 +148,7 @@ Use [ref](https://v3.vuejs.org/guide/component-template-refs.html) to get Search
|
|||||||
| Name | Description | Attribute | Return value |
|
| Name | Description | Attribute | Return value |
|
||||||
| ----- | ------------------- | --------- | ------------ |
|
| ----- | ------------------- | --------- | ------------ |
|
||||||
| focus | Trigger input focus | - | - |
|
| focus | Trigger input focus | - | - |
|
||||||
|
| blur | Trigger input blur | - | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -164,6 +164,7 @@ export default {
|
|||||||
| 方法名 | 说明 | 参数 | 返回值 |
|
| 方法名 | 说明 | 参数 | 返回值 |
|
||||||
| ------ | -------------- | ---- | ------ |
|
| ------ | -------------- | ---- | ------ |
|
||||||
| focus | 获取输入框焦点 | - | - |
|
| focus | 获取输入框焦点 | - | - |
|
||||||
|
| blur | 取消输入框焦点 | - | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -88,6 +88,12 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const blur = () => {
|
||||||
|
if (filedRef.value) {
|
||||||
|
filedRef.value.blur();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const fieldPropNames = [
|
const fieldPropNames = [
|
||||||
'leftIcon',
|
'leftIcon',
|
||||||
'rightIcon',
|
'rightIcon',
|
||||||
@ -116,7 +122,7 @@ export default createComponent({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
useExpose({ focus });
|
useExpose({ focus, blur });
|
||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<div
|
<div
|
||||||
|
2
types/search.d.ts
vendored
2
types/search.d.ts
vendored
@ -2,4 +2,6 @@ import { VanComponent } from './component';
|
|||||||
|
|
||||||
export class Search extends VanComponent {
|
export class Search extends VanComponent {
|
||||||
focus(): void;
|
focus(): void;
|
||||||
|
|
||||||
|
blur(): void;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user