Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NidusP opened this issue Sep 27, 2022 · 1 comment 路 May be fixed by #642
Open

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

NidusP opened this issue Sep 27, 2022 · 1 comment 路 May be 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锛宨t 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
@KaelWD KaelWD linked a pull request May 15, 2023 that will close this issue
13 tasks
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