|
|
@@ -8,11 +8,10 @@ The user can enter content in the text box.
|
|
|
|
|
|
``` javascript
|
|
|
import { createApp } from 'vue';
|
|
|
-import { Input,Icon } from '@nutui/nutui';
|
|
|
+import { Input } from '@nutui/nutui';
|
|
|
|
|
|
const app = createApp();
|
|
|
app.use(Input);
|
|
|
-app.use(Icon);
|
|
|
|
|
|
```
|
|
|
|
|
|
@@ -26,7 +25,6 @@ The value of field is bound with `v-model`.
|
|
|
<template>
|
|
|
<nut-input
|
|
|
v-model="state.text"
|
|
|
- label="Text"
|
|
|
placeholder="Text"
|
|
|
/>
|
|
|
</template>
|
|
|
@@ -56,34 +54,24 @@ Use `type` prop to custom different type fields.
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-input
|
|
|
- label="Text"
|
|
|
placeholder="Text"
|
|
|
v-model="state.text"
|
|
|
/>
|
|
|
<nut-input
|
|
|
- label="Password"
|
|
|
placeholder="Password"
|
|
|
v-model="state.password"
|
|
|
type="password"
|
|
|
/>
|
|
|
<nut-input
|
|
|
- label="Number"
|
|
|
placeholder="Number"
|
|
|
v-model="state.number"
|
|
|
type="number"
|
|
|
/>
|
|
|
<nut-input
|
|
|
- label="Digit"
|
|
|
placeholder="Digit"
|
|
|
v-model="state.digit"
|
|
|
type="digit"
|
|
|
/>
|
|
|
- <nut-input
|
|
|
- label="Tel"
|
|
|
- placeholder="Tel"
|
|
|
- v-model="state.tel"
|
|
|
- type="tel"
|
|
|
- />
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { reactive } from 'vue';
|
|
|
@@ -94,7 +82,6 @@ Use `type` prop to custom different type fields.
|
|
|
password: '',
|
|
|
number: '',
|
|
|
digit: '',
|
|
|
- tel: ''
|
|
|
});
|
|
|
return {
|
|
|
state
|
|
|
@@ -115,13 +102,11 @@ Use `readonly` to set the input box to read-only status, and use `disabled` to s
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-input
|
|
|
- label="Text"
|
|
|
placeholder="Readonly"
|
|
|
v-model="state.readonly"
|
|
|
readonly
|
|
|
/>
|
|
|
<nut-input
|
|
|
- label="Text"
|
|
|
placeholder="Disabled"
|
|
|
v-model="state.disabled"
|
|
|
disabled
|
|
|
@@ -145,24 +130,16 @@ Use `readonly` to set the input box to read-only status, and use `disabled` to s
|
|
|
|
|
|
:::
|
|
|
|
|
|
-### Show Icon
|
|
|
+### Show Clear Icon
|
|
|
|
|
|
-The user can enter content in the text box. Configure the icons on both sides of the input box through `left-icon` and `right-icon`, and display the clear icon during the input process by setting `clearable`. Need to reference the `Icon` component
|
|
|
+Display the clear icon during the input process by setting `clearable`.
|
|
|
|
|
|
:::demo
|
|
|
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-input
|
|
|
- v-model="state.showIcon"
|
|
|
- label="Text"
|
|
|
- placeholder="Show Icon"
|
|
|
- left-icon="dongdong"
|
|
|
- right-icon="ask2"
|
|
|
- />
|
|
|
- <nut-input
|
|
|
v-model="state.clear"
|
|
|
- label="Text"
|
|
|
placeholder="Show Clear Icon"
|
|
|
clearable
|
|
|
clearSize="14"
|
|
|
@@ -173,8 +150,6 @@ The user can enter content in the text box. Configure the icons on both sides of
|
|
|
export default {
|
|
|
setup() {
|
|
|
const state = reactive({
|
|
|
- showIcon: '',
|
|
|
- required: '',
|
|
|
clear:''
|
|
|
});
|
|
|
return {
|
|
|
@@ -186,41 +161,26 @@ The user can enter content in the text box. Configure the icons on both sides of
|
|
|
```
|
|
|
|
|
|
:::
|
|
|
-### Error Info
|
|
|
+### Use With Form
|
|
|
|
|
|
-Use `error` or `error-message` to show error info.
|
|
|
+Use in combination with `nut-form` and `nut-form-item`
|
|
|
|
|
|
:::demo
|
|
|
|
|
|
```html
|
|
|
<template>
|
|
|
- <nut-input
|
|
|
- v-model="state.required"
|
|
|
- label="Text"
|
|
|
- placeholder="Required"
|
|
|
- required
|
|
|
- />
|
|
|
- <nut-input
|
|
|
- v-model="state.error1"
|
|
|
- label="Text"
|
|
|
- placeholder="Error"
|
|
|
- error
|
|
|
- />
|
|
|
- <nut-input
|
|
|
- v-model="state.error2"
|
|
|
- label="Text"
|
|
|
- placeholder="Error Message"
|
|
|
- error-message="Error Message"
|
|
|
- />
|
|
|
+ <nut-form :model-value="state">
|
|
|
+ <nut-form-item label="Text" label-align="center">
|
|
|
+ <nut-input v-model="state.val1" placeholder="Text" :border="false" />
|
|
|
+ </nut-form-item>
|
|
|
+ </nut-form>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { reactive } from 'vue';
|
|
|
export default {
|
|
|
setup() {
|
|
|
const state = reactive({
|
|
|
- required: '',
|
|
|
- error1: '',
|
|
|
- error2: '',
|
|
|
+ val1: '',
|
|
|
});
|
|
|
return {
|
|
|
state
|
|
|
@@ -232,42 +192,6 @@ Use `error` or `error-message` to show error info.
|
|
|
|
|
|
:::
|
|
|
|
|
|
-### Insert Button
|
|
|
-
|
|
|
-Use `button` slot to insert button.
|
|
|
-
|
|
|
-:::demo
|
|
|
-
|
|
|
-```html
|
|
|
-<template>
|
|
|
- <nut-input
|
|
|
- v-model="state.buttonVal"
|
|
|
- label="Code"
|
|
|
- placeholder="Please enter code"
|
|
|
- clearable
|
|
|
- center
|
|
|
- >
|
|
|
- <template #button>
|
|
|
- <nut-button size="small" type="primary">Send</nut-button>
|
|
|
- </template>
|
|
|
- </nut-input>
|
|
|
-</template>
|
|
|
-<script lang="ts">
|
|
|
- import { reactive } from 'vue';
|
|
|
- export default {
|
|
|
- setup() {
|
|
|
- const state = reactive({
|
|
|
- buttonVal: ''
|
|
|
- });
|
|
|
- return {
|
|
|
- state
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
-</script>
|
|
|
-```
|
|
|
-
|
|
|
-:::
|
|
|
|
|
|
### Format Value
|
|
|
|
|
|
@@ -279,14 +203,12 @@ Use `formatter` prop to format the input value.
|
|
|
<template>
|
|
|
<nut-input
|
|
|
v-model="state.format1"
|
|
|
- label="Text"
|
|
|
placeholder="Format On Change"
|
|
|
:formatter="formatter"
|
|
|
format-trigger="onChange"
|
|
|
/>
|
|
|
<nut-input
|
|
|
v-model="state.format2"
|
|
|
- label="Text"
|
|
|
placeholder="Format On Blur"
|
|
|
:formatter="formatter"
|
|
|
format-trigger="onBlur"
|
|
|
@@ -321,9 +243,8 @@ After setting the `maxlength` and `show-word-limit` attributes, word count will
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-input
|
|
|
- v-model="state.textarea"
|
|
|
- label="Text"
|
|
|
- type="textarea"
|
|
|
+ v-model="state.text"
|
|
|
+ type="text"
|
|
|
show-word-limit
|
|
|
rows="2"
|
|
|
max-length="50"
|
|
|
@@ -335,7 +256,7 @@ After setting the `maxlength` and `show-word-limit` attributes, word count will
|
|
|
export default {
|
|
|
setup() {
|
|
|
const state = reactive({
|
|
|
- textarea: ''
|
|
|
+ text: ''
|
|
|
});
|
|
|
return {
|
|
|
state
|
|
|
@@ -347,44 +268,6 @@ After setting the `maxlength` and `show-word-limit` attributes, word count will
|
|
|
|
|
|
:::
|
|
|
|
|
|
-### Input Align
|
|
|
-
|
|
|
-Use `label-align` prop to align the label, `input-align` prop to align the input value
|
|
|
-
|
|
|
-:::demo
|
|
|
-
|
|
|
-```html
|
|
|
-<template>
|
|
|
- <nut-input
|
|
|
- v-model="state.align1"
|
|
|
- label="Text"
|
|
|
- label-align="right"
|
|
|
- placeholder="Label Align"
|
|
|
- />
|
|
|
- <nut-input
|
|
|
- v-model="state.align2"
|
|
|
- label="Text"
|
|
|
- input-align="right"
|
|
|
- placeholder="Input Align"
|
|
|
- />
|
|
|
-</template>
|
|
|
-<script lang="ts">
|
|
|
- import { reactive } from 'vue';
|
|
|
- export default {
|
|
|
- setup() {
|
|
|
- const state = reactive({
|
|
|
- align1: '',
|
|
|
- align2: ''
|
|
|
- });
|
|
|
- return {
|
|
|
- state
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
-</script>
|
|
|
-```
|
|
|
-
|
|
|
-:::
|
|
|
|
|
|
### No Border
|
|
|
|
|
|
@@ -395,13 +278,11 @@ Use `label-align` prop to align the label, `input-align` prop to align the input
|
|
|
<nut-input
|
|
|
v-model="state.noBorder1"
|
|
|
:border="false"
|
|
|
- label="Text"
|
|
|
placeholder="No Border"
|
|
|
/>
|
|
|
<nut-input
|
|
|
v-model="state.noBorder2"
|
|
|
:border="false"
|
|
|
- label="Text"
|
|
|
placeholder="No Border"
|
|
|
/>
|
|
|
</template>
|
|
|
@@ -430,9 +311,6 @@ Use `label-align` prop to align the label, `input-align` prop to align the input
|
|
|
<template>
|
|
|
<nut-input
|
|
|
v-model="state.event"
|
|
|
- label="Text"
|
|
|
- left-icon="dongdong"
|
|
|
- right-icon="ask2"
|
|
|
clearable
|
|
|
placeholder="Event"
|
|
|
@update:model-value="change"
|
|
|
@@ -441,8 +319,6 @@ Use `label-align` prop to align the label, `input-align` prop to align the input
|
|
|
@clear="clear"
|
|
|
@click="click"
|
|
|
@click-input="clickInput"
|
|
|
- @click-left-icon="clickLeftIcon"
|
|
|
- @click-right-icon="clickRightIcon"
|
|
|
/>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
@@ -470,12 +346,6 @@ Use `label-align` prop to align the label, `input-align` prop to align the input
|
|
|
const clickInput = (event: Event) => {
|
|
|
console.log('clickInput:', event);
|
|
|
};
|
|
|
- const clickLeftIcon = (event: Event) => {
|
|
|
- console.log('clickLeftIcon:', event);
|
|
|
- };
|
|
|
- const clickRightIcon = (event: Event) => {
|
|
|
- console.log('clickRightIcon:', event);
|
|
|
- };
|
|
|
|
|
|
return {
|
|
|
state,
|
|
|
@@ -485,8 +355,6 @@ Use `label-align` prop to align the label, `input-align` prop to align the input
|
|
|
focus,
|
|
|
click,
|
|
|
clickInput,
|
|
|
- clickLeftIcon,
|
|
|
- clickRightIcon
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
@@ -500,14 +368,9 @@ Use `label-align` prop to align the label, `input-align` prop to align the input
|
|
|
| Attribute | Description | Type | Default |
|
|
|
|--------------|----------------------------------------|----------------|---------|
|
|
|
| v-model | Input value, two-way binding | String | - |
|
|
|
-| type | Input type, support all native types and `textarea` `number` `digit` type | String | `text` |
|
|
|
+| type | Input type, support all native types and `number` `digit` type | String | `text` |
|
|
|
| placeholder | Placeholder when the input box is empty | String | - |
|
|
|
-| label | Left text | String | - |
|
|
|
-| label-class | Left text extra class name | String | - |
|
|
|
-| label-width | Label width, default unit is `px` | String、Number | `80` |
|
|
|
-| label-align | Label align, eg `left`、`center`、`right` | String | `left` |
|
|
|
| input-align | Input align, eg `left`、`center`、`right` | String | `left` |
|
|
|
-| colon | Whether to display colon after label | Boolean | `false` |
|
|
|
| required | Whether to show required mark | Boolean | `false` |
|
|
|
| border | Whether to show inner borde | Boolean | `true` |
|
|
|
| disabled | Whether to disable field | Boolean | `false` |
|
|
|
@@ -515,16 +378,9 @@ Use `label-align` prop to align the label, `input-align` prop to align the input
|
|
|
| autofocus | Whether to auto focus, unsupported in iOS | Boolean | `false` |
|
|
|
| max-length | Max length of value | String、Number | - |
|
|
|
| clearable | Whether to be clearable | Boolean | `false` |
|
|
|
-| clear-icon | Clear Icon name, [name of icon](#/en-US/component/icon) | String | `mask-close` |
|
|
|
| clear-size | Clear Icon `font-size` | String | `14` |
|
|
|
-| left-icon | Left side Icon name, [name of icon](#/en-US/component/icon) | String | - |
|
|
|
-| right-icon | Right side Icon name, [name of icon](#/en-US/component/icon) | String | - |
|
|
|
-| left-icon-size | Left side Icon `font-size` | String | `14` |
|
|
|
-| right-icon-size | Right side Icon `font-size` | String | `14` |
|
|
|
| show-word-limit | Whether to show word limit, need to set the `max-length` prop | Boolean | `false` |
|
|
|
| error | Whether to mark the input content in red | Boolean | `false` |
|
|
|
-| error-message | Error message | String、Number | - |
|
|
|
-| error-message-align | Error message align, eg `left`、`center`、`right` | String | - |
|
|
|
| formatter | Input value formatter | `(val: string) => string` | - |
|
|
|
| format-trigger | When to format value, eg `onChange`、`onBlur` | String | - |
|
|
|
| confirm-type | The text of the button in the lower right corner of the keyboard, only valid when `type='text'`, eg `send`, `search`, `next`, ` go`, `done` | String | `done` |
|
|
|
@@ -539,16 +395,11 @@ Use `label-align` prop to align the label, `input-align` prop to align the input
|
|
|
| clear | Emitted when the clear icon is clicked | event |
|
|
|
| click | Emitted when component is clicked | event |
|
|
|
| click-input | Emitted when the input is clicked | event |
|
|
|
-| click-left-icon | Emitted when the left icon is clicked | event |
|
|
|
-| click-right-icon | Emitted when the right icon is clicked | event |
|
|
|
|
|
|
### Slots
|
|
|
-
|
|
|
| Name | Description |
|
|
|
|-------|----------|
|
|
|
-| button | Insert button |
|
|
|
-| input | Custom input |
|
|
|
-| rightExtra | Customize the rightmost area of the input box |
|
|
|
+| clear | Customize the end of the input box to clear the button |
|
|
|
|
|
|
## Theming
|
|
|
|
|
|
@@ -569,4 +420,3 @@ The component provides the following CSS variables, which can be used to customi
|
|
|
|
|
|
|
|
|
|
|
|
-
|