20

I have a vue.js template that has a todo prop. I want to dynamically set the id value of each element. This what I have tried so far, is something like this possible and if not what are some other options?

<canvas class="canvas" id="cv`${{todo.id}}`" width="500" height="700"></canvas> 

2 Answers 2

57

This should work.

:id="`cv${todo.id}`"

or

v-bind:id="`cv${todo.id}`"

Or do it the old-school way if the browser doesn't support string interpolation:

:id="'cv' + todo.id"

This is essentially a duplicate but I couldn't determine how to escape the backticks in a comment!

Sign up to request clarification or add additional context in comments.

1 Comment

I was facing problem with laravel project with "{{}}" not working. But you solution solve all of my problem.. thanks a lot.
-1

This helped me to solve my problem :

<input v-bind:id="object.value1" v-model="object.value2"/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.