First letter auto capitalizing of v-text-field in vuejs vuetify
·
Answer a question
I am trying to captitalize first letter of v-text-field in vuejs but unbale to do. How to do this?

first letter should be auto capital when i am input text like in pic.
Answers
Another way would be to use a watcher. This triggers whenever firstName is changed.
<template>
<v-text-field v-model="firstName" label="First Name"></v-text-field>
</template>
<script>
export default {
data() {
return {
firstName: "",
};
},
methods: {
capitalizeFirstLetter: (str) => {
return str ? str[0].toUpperCase() + str.slice(1) : "";
},
},
watch: {
firstName: function(newValue) {
this.firstName = this.capitalizeFirstLetter(newValue);
},
},
};
</script>
更多推荐

所有评论(0)