我正在尝试在输入事件时将用户输入转换为大写
因此,每当我在输入字段中键入键时,都会遇到以下问题
Here is the link to JS fiddle https://jsfiddle.net/aeL051od/ to reproduce the issue
new Vue({
el: "#app",
data() {
return {
input: null
}
},
methods: {
handleInput(e) {
this.input = e.target.value ?
e.target.value.toString().toUpperCase() :
e.target.value;
}
}
});Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<input type="text" v-model="input" @input="handleInput"> {{ input }}
<!-- {{ input }} is just for reference -->
</div>Run Code Online (Sandbox Code Playgroud)