I'm struggling my mind on how to obtain a boolean value from an input text if there is typed text inside or not. I mean I would like to know how to obtain true/false from an text input tag depending if it contains text or not. I'm using Vue js 2.
you could use a computed variable:
<template>
<input type="text" v-model="text"/>
</template>
<script>
export default {
name: 'TestComponent',
data(){
return {
text:''
}
},
computed: {
isFilled(){
return this.text.trim().length > 0
}
}
}
</script>
<style scoped>
</style>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.