docs: add useCustomFieldValue document (#9202)

This commit is contained in:
neverland
2021-08-07 21:33:46 +08:00
committed by GitHub
parent 1bfcbab2fa
commit 5852b80a17
4 changed files with 121 additions and 0 deletions
@@ -0,0 +1,50 @@
# useCustomFieldValue
### Intro
Used to custom Field value.
## Usage
### Basic Usage
If you want to custom Form items, you can insert your component into the `input` slot of the Field component, and call the `useCustomFieldValue` method inside your custom component.
#### MyComponent
```js
// MyComponent.vue
import { useCustomFieldValue } from '@vant/use';
export default {
setup() {
useCustomFieldValue(() => 'Some value');
},
};
```
#### Form
```html
<van-form>
<van-field name="my-field" label="Custom Field">
<template #input>
<my-component />
</template>
</van-field>
</van-form>
```
## API
### Type Declarations
```ts
function useCustomFieldValue(customValue: () => unknown): void;
```
### Params
| Name | Description | Type | Default Value |
| ----------- | --------------------------- | --------------- | ------------- |
| customValue | Function to get field value | _() => unknown_ | - |