Skip to content

v-model with custom element that wrap checkbox. #3838

@phattarachai

Description

@phattarachai

Hi,

I am using vuejs 2.0.1 and I want to create a component that looks like this:

    <vue-checkbox v-model="page.ads_able"></vue-checkbox>

As from the api page that v-model is a syntactic sugar combinding :value and @input.

So I write a template with a props name value and a method for input event like this:

...
<input type="checkbox" :value="value" @input="onInput" />
...
...
props: {
        value: {},
},
methods: {
        onInput(event) {
            this.$emit('input', event.target.value)
        }
}
...

But it doesn't work. I don't know if there any special care about checked attribute of the checkbox. I tried the exact same thing with <select> and it's worked as aspect though. Any suggestion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions