i want to pass dynamic variable into style:
it is possible ??
like that : i try this way but it didn't work :style="
{'width':${parseInt(100 * task.progress)}
% ;}"
this is my task.vue:
<tr v-for="task in tasks.data " v-if=" task.projet_id == key " :key="task.id">
<td >{{ parseInt(100 * task.progress) }}% <div class="progress">
<div class="progress-bar bg-success" role="progressbar" aria-valuenow="0" :style="
{'width':`${parseInt(100 * task.progress)}`% ;}" id="progress"
aria-valuemin="`${parseInt(100 * task.progress)}`" aria-valuemax="100"></div>
</div>
</td>
Yes it is possible to add variables inside
style
. In your case the%
should be inside the quotes.It is not needs to include
;
while adding style since the style data is an object and will be separated bycommas
like this看起来不错,除了一些语法错误:
;
would be out of place%
needs to be inside the string