Skip to content

Why use v-if after v-for in the list of attribute order of Styleguide #1245

Closed
@MachinisteWeb

Description

@MachinisteWeb

Hi @chrisvfritz,

I read in the style-guide/index.md i am currently translated the following thing:

v-for should be before v-if in the order of document.

https://vuejs.org/v2/style-guide/#Element-attribute-order-recommended

When I parse myself an HTML Vue template, I check if the v-if expression of current element I read is true before start to read more about this element and all its child elements.

For exemple, in this case:

<li v-if="..." v-for="...">...</li>
<li v-else-if="..." v-for="...">...</li>
<li v-else-if="..." v-for="...">...</li>
<li v-else-if="..." v-for="...">...</li>
<li v-else-if="..." v-for="...">...</li>
<li v-else >...</li>

I want first know witch case I want before know more about what this element do (read v-for and continue to parse this subpart).

So what is the reason of this order if it's not the reading flow?

I see in the original Markdown document the two have 2. :

2. **Rendu de liste** ...
...
2. **Conditionals** ...

I think it's maybe because of I just explained. But, in the HTML rendering of documentation, there is no way to allows two points of an « ordered list (<ol>) » to have twice « 2. » just like .md file.

What's your throughs?

EDIT : maybe the good practice is never use v-if with v-for but I not still read this in styleguide and in my tested case, v-if work fine with v-for on the same tag.

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