Skip to content

[BUG] v-model arguments is not work in tsx #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NidusP opened this issue Sep 27, 2022 · 1 comment · Fixed by #642
Closed

[BUG] v-model arguments is not work in tsx #602

NidusP opened this issue Sep 27, 2022 · 1 comment · Fixed by #642
Labels
bug Something isn't working

Comments

@NidusP
Copy link

NidusP commented Sep 27, 2022

🐛 Bug description

when I use v-model:[key]="title" in tsx,it is not work. Is there a problem with my writing?

thanks!

// test.tsx
import { defineComponent, ref } from "vue";
import MyComp from "./my-comp";

export default defineComponent({
    setup(){
        const title = ref('this is title')
        const key = 'title'
        return () => <>
            test comp (tsx)
            <MyComp v-model:title={ title.value }></MyComp>
            <MyComp v-model={ [title.value, 'title']}></MyComp>
            
            <h4 style="color: red">this is not working </h4>
            <MyComp v-model={ [title.value, key]}></MyComp>
        </>
    }
})
// my-comp.tsx
import { defineComponent, PropType } from "vue";

export default defineComponent({
    props: {
        title: String as PropType<string>,
        'update:title': Function as PropType<() => void>
    },
    setup(props, { emit }){
        return () => <div>
            <div>{ props.title }</div>
            <button onClick={ () => emit('update:title', props.title + '_a') }>change</button>
        </div>
    }
})

🏞 Desired result

🚑 Other information

@NidusP NidusP added the bug Something isn't working label Sep 27, 2022
@funny-family
Copy link

funny-family commented Sep 29, 2022

@NidusP, try this

// my-comp.tsx
import { defineComponent, PropType } from "vue";

export default defineComponent<{ 'v-model'?: any }>({
    props: {
        title: String as PropType<string>,
        'update:title': Function as PropType<() => void>
    },
    setup(props, { emit }){
        return () => <div>
            <div>{ props.title }</div>
            <button onClick={ () => emit('update:title', props.title + '_a') }>change</button>
        </div>
    }
})
// test.tsx
import { defineComponent, ref } from "vue";
import MyComp from "./my-comp";

export default defineComponent({
    setup(){
        const title = ref('this is title')
        const key = 'title'
        return () => <>
            test comp (tsx)
            <MyComp v-model={[title.value, "title"]}></MyComp>
            <MyComp v-model={[title.value, 'title']}></MyComp>
            
            <h4 style="color: red">this is not working </h4>
            <MyComp v-model={[title.value, key]}></MyComp>
        </>
    }
})

this will not work because v-model must be compiled
<MyComp v-model={[title.value, key]}></MyComp>

See more precise example here.

KaelWD added a commit to KaelWD/jsx-next that referenced this issue May 15, 2023
sxzz pushed a commit to KaelWD/jsx-next that referenced this issue Sep 11, 2024
@sxzz sxzz closed this as completed in #642 Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants