G
G
grigorie19902018-03-21 17:47:43
Vue.js
grigorie1990, 2018-03-21 17:47:43

How to make checkbox return '0' or '1' in VUE?

Hello,
I have 0 or 1 in a column in my database, I want the checkbox to give such results, and it is NULL or on.
Thank you!

<template>
    <div>
       <input type="checkbox" name="coworker" v-bind:true-value="1" v-bind:false-value="0" v-model="coworker">
           <label for="checkbox">{{coworker}}</label>
    </div>
</template>

 export default {
        props: ['user'],
    
        data: function () {
            var user = JSON.parse(this.user);
            return {
                 coworker: user[0].coworker
            }
        },
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2018-03-21
@grigorie1990

Works for me https://jsfiddle.net/wcx1o9ah/3/

R
Roman Kitaev, 2018-03-21
@deliro

Why not like this? https://jsfiddle.net/deliro/1yaqj0o8/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question