Vue how to concat dynamic id with field from v-for loop + string? Vue how to concat dynamic id with field from v-for loop + string? vue.js vue.js

Vue how to concat dynamic id with field from v-for loop + string?


You don't need to use the template {{prop}}, just use plain JavaScript string concatenation.

<th v-for="(field, key) in lists[$route.params.model][$route.params.status].fields"     :id="'order_by' + field"     :key="key">                            ...</th>


If you are generating row by writing template about each row. Then i think this is the solution for you.

<TradeTableItem v-for="(debtReserve, index) in debtReserves" :key="debtReserve.id" :debtReserve="debtReserve" :market="market" :id="'reserve' + index"></TradeTableItem>

In upper step, we generated id for each rows.

And in TradeTableItem (your template where we are populating, the table rows), Write id as :id="this.id" where this.id is a part of props.

Hope this helps