Try this instead:
<tr v-for="(user, index) in users">
<td>@{{ index + 1 }}</td>
....
I am making a for loop with vuejs and displaying a list of users in a table. I want to add the id of users to the action attribute of a form element or classes of the elements in the table items.
This is my html:
<tr v-for="(user, key, index) in users">
<td>@{{ key+1 }}</td>
<td v-text="user.name"></td>
<td>@{{ user.email }}</td>
<td>@{{ user.status }}</td>
<td>
<div class="btn-group pull-rights" role="group" aria-label="action-btns">
<form id="statusform" :action="baseUrl+/user.id" method="POST">
<label class="ui-switch mt-1 mr-2">
<input @click="onSwitchStatus(user.id)" type="checkbox" :checked="user.status == 'active'" :value="user.status">
</form>
</div>
</td>
Am using laravel. I want the action attribute of the form to be for example… ‘localhost/project/user/edit/1/’ but it is not working. Can anyone help me;
@nanadjei2 I'm aware that's not the problem. As far as I'm aware, v-for only takes 2 parameters, that's why I changed that. Also, my bad for not looking closer at your url in the form, as I figured the rest of the code could have stayed the same. You need to change to action to something like this:
<form :action=`${baseUrl}/${user.id}` method="POST">
Please or to participate in this conversation.