bart
157
1
Vue

Pass Javascript variable as property

Posted 2 years ago by bart

Hey guys,

sometimes you stuck like I currently do. I created a vue component and want to pass a simple JS object as property. I don't know how to do that :(

<script>
let my_prop = {
                firstname: 'Jack',
                lastname: 'Bauer'
            };
</script>

<my-component user="my_prop"></my-component>

I tried everything from :user="my_prop" until user="{{ my_prop }}".

Do you have any idea? Thanks!

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.