vuejs-challenges icon indicating copy to clipboard operation
vuejs-challenges copied to clipboard

305 - 大写

Open PoliWen opened this issue 2 years ago • 0 comments

// myInput.vue
<script setup>
import { ref,defineProps,defineEmits } from 'vue'
const props = defineProps({
    modelValue:String,
    modelModifiers:{default:()=>({})}
})
const emit = defineEmits(['update:modelValue'])
const emitValue = (e)=>{
    let value = e.target.value
    if(props.modelModifiers.capitalize){
        value = value.charAt(0).toUpperCase()+ value.slice(1)
    }
    e.target.value = value
    emit('update:modelValue',value)
}
</script>

<template>
    <input type="text" :value="modelValue" @input="emitValue"/>
</template>
    

PoliWen avatar Sep 04 '22 12:09 PoliWen