Skip to content

Iterate "tr" element recursively #5674

@rafi16d

Description

@rafi16d

Version

2.3.3

Reproduction link

https://jsfiddle.net/rafi16d/puwcs9ay/

Steps to reproduce

I would like to iterate recursively on an objects to get a nested table.

I have this template:

<script type="text/x-template">
    <tr>
        <td><a v-on:click="toggle">[ ]</a></td>
        <td>...</td>
    </tr>
    <tr is="row-item"  v-show="open" ...></tr>
</script>

It's recursive, so each line tr has an other hidden line tr below.

When the user click on the [ ] on the parent line, the children lines will appear.

I already try to wrap the content within a tbody tag, but then I get tbody inside tbody, which is still an illegal table layout and breaks it.

<script type="text/x-template">
    <tbody>
        <tr>
            <td>...</td>
            <td>...</td>
        </tr>
        <tr is="row-item" ...></tr>
    </tbody>
</script>

Vue@1.x doesn't require exactly one root element. How can I do without ?

Any idea on how to solve this?

Thanks.

What is expected?

Use multiple elements in template. Or another solution.

What is actually happening?

Error: Component template should contain exactly one root element


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions