docs(input): focus & blur manually

This commit is contained in:
07akioni 2021-07-04 12:55:20 +08:00
parent ad4c055dc2
commit f61990c139
6 changed files with 81 additions and 2 deletions

View File

@ -76,7 +76,7 @@ tree
这些方法可以帮助你在非受控的状态下改变表格,但是,并不推荐在异步的状况下使用这些方法。如果需要异步操作,最好用**受控**的方式使用表格。
| 名称 | 参数 | 说明 |
| 名称 | 类型 | 说明 |
| --- | --- | --- |
| clearFilters | `() => void` | 清空所有的 filter 状态 |
| clearSorter | `() => void` | 清空所有的 sort 状态 |

View File

@ -0,0 +1,30 @@
# Focus & Blur Manually
```html
<n-space vertical>
<n-space>
<n-button @click="handleFocus">Focus</n-button>
<n-button :focusable="false" @click="handleBlur">Blur</n-button>
</n-space>
<n-input ref="inputInstRef" />
</n-space>
```
```js
import { defineComponent, ref } from 'vue'
export default defineComponent({
setup () {
const inputInstRef = ref(null)
return {
inputInstRef,
handleFocus () {
inputInstRef.value.focus()
},
handleBlur () {
inputInstRef.value.blur()
}
}
}
})
```

View File

@ -17,6 +17,7 @@ pair
input-group
passively-activated
count
focus
```
## Props
@ -72,3 +73,12 @@ count
| Name | Parameters | Description |
| ------- | ---------- | ----------- |
| default | `()` | |
## Methods
### Input Methods
| Name | Type | Description |
| ----- | ---------- | -------------------- |
| blur | () => void | Blur input element. |
| focus | () => void | Focus input element. |

View File

@ -0,0 +1,30 @@
# 手动 Focus & Blur
```html
<n-space vertical>
<n-space>
<n-button @click="handleFocus">Focus</n-button>
<n-button :focusable="false" @click="handleBlur">Blur</n-button>
</n-space>
<n-input ref="inputInstRef" />
</n-space>
```
```js
import { defineComponent, ref } from 'vue'
export default defineComponent({
setup () {
const inputInstRef = ref(null)
return {
inputInstRef,
handleFocus () {
inputInstRef.value.focus()
},
handleBlur () {
inputInstRef.value.blur()
}
}
}
})
```

View File

@ -17,6 +17,7 @@ pair
input-group
passively-activated
count
focus
```
## Props
@ -73,3 +74,12 @@ count
| 属性 | 类型 | 说明 |
| ------- | ---- | ---- |
| default | `()` | |
## Methods
### Input Methods
| 名称 | 类型 | 说明 |
| ----- | ---------- | ---------------- |
| blur | () => void | Blur input 元素 |
| focus | () => void | Focus input 元素 |

View File

@ -85,7 +85,6 @@ const inputProps = {
},
autofocus: Boolean,
inputProps: Object as PropType<TextareaHTMLAttributes | InputHTMLAttributes>,
resizable: {
type: Boolean,
default: true