最佳答案
另一种方法是使用 watcher .每当 firstName
更改时都会触发。
<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>
关于vue.js - vuejs vuetify中v-text-field的首字母自动大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61728294/