[Vuejs]-Vue js obtain boolean value from an input tag

0👍

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>

Leave a comment