Skip to content

Commit f8c24f3

Browse files
committed
feature: original file copy
1 parent 2736bdb commit f8c24f3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const sidebar = {
129129
'migration/render-function-api',
130130
'migration/slots-unification',
131131
'migration/transition',
132+
'migration/v-if-v-for',
132133
'migration/v-model',
133134
'migration/v-bind'
134135
]

src/guide/migration/v-if-v-for.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: v-if vs. v-for Precedence
3+
badges:
4+
- breaking
5+
---
6+
7+
# {{ $frontmatter.title }} <MigrationBadges :badges="$frontmatter.badges" />
8+
9+
## Overview
10+
11+
- **BREAKING**: If used on the same element, `v-if` will have higher precedence than `v-for`
12+
13+
## Introduction
14+
15+
Two of the most commonly used directives in Vue.js are `v-if` and `v-for`. So it's no surprise that there comes a time when developers want to use both together. While this is not a recommended practice, there may be times when this is necessary, so we wanted to provide guidance for how it works.
16+
17+
## 2.x Syntax
18+
19+
In 2.x, when using `v-if` and `v-for` on the same element, `v-for` would take precedence.
20+
21+
## 3.x Syntax
22+
23+
In 3.x, `v-if` will always have the higher precedence than `v-for`.
24+
25+
## Migration Strategy
26+
27+
It is recommended to avoid using both on the same element due to the syntax ambiguity.
28+
29+
Rather than managing this at the template level, one method for accomplishing this is to create a computed property that filters out a list for the visible elements.

0 commit comments

Comments
 (0)