1

I would like to hava all tr as a router link in my table, but when I add this before tr, then every css from table disappear and my View looks bad. Is a possibility to do this better?

<table v-if="seenOrders" id="ordersTable" class="table">
        <tr>
            <th>Numer zamówienia</th>
            <th>Imię</th>
            <th>Telefon</th>
            <th>Email</th>
            <th>Status</th>
            <th>Data zamówienia</th>
        </tr>

        <router-link to="/orderDetail" class="order-row" >
        <tr v-for="order in orders" v-on:click="details(order.id)">
            <td>{{order.number}}</td>
            <td>{{order.client_name}}</td>
            <td>{{order.phone}}</td>
            <td>{{order.email}}</td>
            <td>{{order.actual_status}}</td>
            <td>{{order.order_date}}</td>
        </tr>
        </router-link>
    </table>

1 Answer 1

1

<router-limk> will by default render as a <a> element. If you want to change how the <router-link> should render use the tag prop (in your case <tr>)

<router-link to="/orderDetail" tag="tr" class="order-row" >

So your code should be

<table v-if="seenOrders" id="ordersTable" class="table">
    <tr>
        <th>Numer zamówienia</th>
        <th>Imię</th>
        <th>Telefon</th>
        <th>Email</th>
        <th>Status</th>
        <th>Data zamówienia</th>
    </tr>

    <router-link to="/orderDetail" v-for="order in orders" tag="tr" class="order-row" >
        <td>{{order.number}}</td>
        <td>{{order.client_name}}</td>
        <td>{{order.phone}}</td>
        <td>{{order.email}}</td>
        <td>{{order.actual_status}}</td>
        <td>{{order.order_date}}</td>
    </router-link>
</table>

See tag section of <router-link>

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

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.