Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting id tag dynamically using vuejs

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> 
like image 899
Taylor Avatar asked Dec 07 '17 23:12

Taylor


1 Answers

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!

like image 54
Bert Avatar answered Sep 24 '22 02:09

Bert