| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <template>
- <up-input :readonly="readonly" :shape="shape" :placeholder="placeholder" :placeholderClass="placeholderClass"
- :suffixIcon="suffixIcon" :border="border" :adjustPosition="adjustPosition" :suffixIconStyle="suffixIconStyle"
- :model-value="inputValue" :disabled="disabled" :maxlength="maxlength" :type="type" :clearable="clearable"
- :placeholderStyle="placeholderStyle" :password="password" :confirm-type="confirmType" :focus="focus"
- :inputAlign="inputAlign" :fontSize="fontSize" :color="color" :prefixIcon="prefixIcon"
- :prefixIconStyle="prefixIconStyle" @clear="clear" @change="change" @update:modelValue="input" @confirm="confirm"
- @keyboardheightchange="keyboardheightchange" @focus="focusChange" @blur="blur"
- :style="{ '--bordercolor': borderColor, '--bgColor': bgColor }">
- <template #prefix>
- <slot name="prefix"></slot>
- </template>
- <template #suffix>
- <slot name="suffix">
- <view class="search_right" @click.stop="search" v-if="suffixIcon">
- <u-icon :name="suffixIcon" color="var(--gray1)" size="20"></u-icon>
- </view>
- </slot>
- </template>
- </up-input>
- </template>
- <script setup>
- import { ref, nextTick, watch } from "vue";
- const props = defineProps({
- placeholder: {
- type: String,
- default: ''
- },
- modelValue: {
- type: [String, Number],
- default: ''
- },
- type: {
- type: String,
- default: 'text'
- },
- clearable: Boolean,
- password: Boolean,
- readonly: Boolean,
- shape: {
- type: String,
- default: 'circle' // circle | square
- },
- suffixIcon: {
- type: String,
- default: ''
- },
- border: {
- type: String,
- default: 'surround' // surround | bottom | none
- },
- suffixIconStyle: {
- type: [String, Object],
- default: ''
- },
- placeholderStyle: {
- type: [String, Object],
- default: 'color: #adb8cc'
- },
- placeholderClass: {
- type: String,
- default: ''
- },
- adjustPosition: Boolean,
- disabled: Boolean,
- maxlength: {
- type: Number,
- default: -1
- },
- confirmType: {
- type: String,
- default: 'done'
- },
- focus: Boolean,
- inputAlign: {
- type: String,
- default: 'left'
- },
- fontSize: {
- type: String,
- default: '14px'
- },
- color: {
- type: String,
- default: 'var(--inputText)'
- },
- prefixIcon: {
- type: String,
- default: ''
- },
- prefixIconStyle: {
- type: [String, Object],
- default: ''
- },
- borderColor: {
- type: String,
- default: 'var(--inputBorder)'
- },
- bgColor: {
- type: String,
- default: 'var(--light)'
- }
- })
- const emit = defineEmits(['update:modelValue', 'search', 'clear', 'change', 'confirm', 'keyboardheightchange', 'focusChange', 'blur'])
- const inputValue = ref(props.modelValue)
- const search = () => {
- emit('search');
- }
- const clear = () => {
- emit('clear')
- }
- const change = (value) => {
- emit('change', value)
- }
- const input = (value) => {
- inputValue.value = value;
- emit('update:modelValue', value)
- }
- const confirm = (value) => {
- emit('confirm', value)
- }
- const keyboardheightchange = () => {
- emit('keyboardheightchange')
- }
- const focusChange = () => {
- emit('focusChange')
- }
- const blur = (value) => {
- emit('blur', value)
- }
- watch(() => props.modelValue, (newValue) => {
- inputValue.value = newValue;
- });
- </script>
- <style lang="less" scoped>
- .u-border {
- border-color: var(--borderColor) !important;
- box-shadow: 0 0 0 1px var(--borderColor) inset;
- }
- .u-input {
- padding: 0 8px !important;
- background-color: var(--inputBg);
- /deep/ .u-input__content__prefix-icon {
- margin-right: 8px;
- }
- /deep/ .uni-input-placeholder{
- color: var(--text-01) !important;
- }
- /deep/ .u-input__content__field-wrapper__field {
- height: 32px;
- }
- }
- </style>
|