todomvc-vue-composition-api icon indicating copy to clipboard operation
todomvc-vue-composition-api copied to clipboard

Do you have an v-model example?

Open yooouuri opened this issue 5 years ago • 3 comments

I am trying the new Composition API but I am not getting v-model on a custom component working...

<custom-component v-model="something"></custom-component>

Inside the custom component, I have a prop called value and a watcher on the prop. But the watcher doesn't trigger..

export default {
        props: {
            value: Boolean,
        },
watch(props.value, (value, value2) => {
                console.info(value);
                console.info(value2);
            });

yooouuri avatar Apr 24 '20 07:04 yooouuri

Hi,

Does it mean it passes down a prop from parent to a child with the name value and this value should change when the parent component modifies the something variable? I haven't tried it myself yet. If it's not working I would raise a ticket in the vue-next repository. They are really helpful.

sonicoder86 avatar Apr 24 '20 08:04 sonicoder86

I meant just like: https://alligator.io/vuejs/add-v-model-support/

But then use the new Composition API

yooouuri avatar Apr 24 '20 08:04 yooouuri

I have examples in my Vue 3 playground

https://github.com/blacksonic/vue-3-playground/blob/master/src-javascript/components/Item.vue

sonicoder86 avatar Dec 27 '20 12:12 sonicoder86