You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hide all style guide links and add outdated warnings on style guide pages (vuejs#3119)
* docs: hide all the style-guide links until it's ready
* docs: add outdated warnings on style guide pages
* docs: adjust v-for with v-if warnings
* docs: add outdated warning to style-guide index
Copy file name to clipboardExpand all lines: src/guide/essentials/conditional.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -110,8 +110,8 @@ Generally speaking, `v-if` has higher toggle costs while `v-show` has higher ini
110
110
111
111
## `v-if` with `v-for` {#v-if-with-v-for}
112
112
113
+
When `v-if` and `v-for` are both used on the same element, `v-if` will be evaluated first. See the [list rendering guide](list#v-for-with-v-if) for details.
114
+
113
115
::: warning Note
114
-
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence. Refer to [style guide](/style-guide/rules-essential#avoid-v-if-with-v-for) for details.
116
+
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence. Refer to [list rendering guide](list#v-for-with-v-if) for details.
115
117
:::
116
-
117
-
When `v-if` and `v-for` are both used on the same element, `v-if` will be evaluated first. See the [list rendering guide](list#v-for-with-v-if) for details.
Copy file name to clipboardExpand all lines: src/guide/essentials/list.md
+11-5Lines changed: 11 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -223,10 +223,6 @@ Similar to template `v-if`, you can also use a `<template>` tag with `v-for` to
223
223
224
224
## `v-for` with `v-if` {#v-for-with-v-if}
225
225
226
-
:::warning Note
227
-
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence. Refer to [style guide](/style-guide/rules-essential#avoid-v-if-with-v-for) for details.
228
-
:::
229
-
230
226
When they exist on the same node, `v-if` has a higher priority than `v-for`. That means the `v-if` condition will not have access to variables from the scope of the `v-for`:
231
227
232
228
```vue-html
@@ -249,6 +245,16 @@ This can be fixed by moving `v-for` to a wrapping `<template>` tag (which is als
249
245
</template>
250
246
```
251
247
248
+
:::warning Note
249
+
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence.
250
+
251
+
There are two common cases where this can be tempting:
252
+
253
+
- To filter items in a list (e.g. `v-for="user in users" v-if="user.isActive"`). In these cases, replace `users` with a new computed property that returns your filtered list (e.g. `activeUsers`).
254
+
255
+
- To avoid rendering a list if it should be hidden (e.g. `v-for="user in users" v-if="shouldShowUsers"`). In these cases, move the `v-if` to a container element (e.g. `ul`, `ol`).
256
+
:::
257
+
252
258
## Maintaining State with `key` {#maintaining-state-with-key}
253
259
254
260
When Vue is updating a list of elements rendered with `v-for`, by default it uses an "in-place patch" strategy. If the order of the data items has changed, instead of moving the DOM elements to match the order of the items, Vue will patch each element in-place and make sure it reflects what should be rendered at that particular index.
@@ -275,7 +281,7 @@ When using `<template v-for>`, the `key` should be placed on the `<template>` co
275
281
`key` here is a special attribute being bound with `v-bind`. It should not be confused with the property key variable when [using `v-for` with an object](#v-for-with-an-object).
276
282
:::
277
283
278
-
[It is recommended](/style-guide/rules-essential#use-keyed-v-for) to provide a `key` attribute with `v-for` whenever possible, unless the iterated DOM content is simple (i.e. contains no components or stateful DOM elements), or you are intentionally relying on the default behavior for performance gains.
284
+
It is recommended to provide a `key` attribute with `v-for` whenever possible, unless the iterated DOM content is simple (i.e. contains no components or stateful DOM elements), or you are intentionally relying on the default behavior for performance gains.
279
285
280
286
The `key` binding expects primitive values - i.e. strings and numbers. Do not use objects as `v-for` keys. For detailed usage of the `key` attribute, please see the [`key` API documentation](/api/built-in-special-attributes#key).
Copy file name to clipboardExpand all lines: src/style-guide/index.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@ outline: deep
4
4
5
5
# Style Guide {#style-guide}
6
6
7
+
::: warning Note
8
+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
9
+
:::
10
+
7
11
This is the official style guide for Vue-specific code. If you use Vue in a project, it's a great reference to avoid errors, bikeshedding, and anti-patterns. However, we don't believe that any style guide is ideal for all teams or projects, so mindful deviations are encouraged based on past experience, the surrounding tech stack, and personal values.
8
12
9
13
For the most part, we also avoid suggestions about JavaScript or HTML in general. We don't mind whether you use semicolons or trailing commas. We don't mind whether your HTML uses single-quotes or double-quotes for attribute values. Some exceptions will exist however, where we've found that a particular pattern is helpful in the context of Vue.
Copy file name to clipboardExpand all lines: src/style-guide/rules-essential.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Priority A Rules: Essential {#priority-a-rules-essential}
2
2
3
+
::: warning Note
4
+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
5
+
:::
6
+
3
7
These rules help prevent errors, so learn and abide by them at all costs. Exceptions may exist, but should be very rare and only be made by those with expert knowledge of both JavaScript and Vue.
4
8
5
9
## Use multi-word component names {#use-multi-word-component-names}
Copy file name to clipboardExpand all lines: src/style-guide/rules-recommended.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Priority C Rules: Recommended {#priority-c-rules-recommended}
2
2
3
+
::: warning Note
4
+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
5
+
:::
6
+
3
7
Where multiple, equally good options exist, an arbitrary choice can be made to ensure consistency. In these rules, we describe each acceptable option and suggest a default choice. That means you can feel free to make a different choice in your own codebase, as long as you're consistent and have a good reason. Please do have a good reason though! By adapting to the community standard, you will:
4
8
5
9
1. Train your brain to more easily parse most of the community code you encounter
Copy file name to clipboardExpand all lines: src/style-guide/rules-strongly-recommended.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Priority B Rules: Strongly Recommended {#priority-b-rules-strongly-recommended}
2
2
3
+
::: warning Note
4
+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
5
+
:::
6
+
3
7
These rules have been found to improve readability and/or developer experience in most projects. Your code will still run if you violate them, but violations should be rare and well-justified.
Copy file name to clipboardExpand all lines: src/style-guide/rules-use-with-caution.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Priority D Rules: Use with Caution {#priority-d-rules-use-with-caution}
2
2
3
+
::: warning Note
4
+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
5
+
:::
6
+
3
7
Some features of Vue exist to accommodate rare edge cases or smoother migrations from a legacy code base. When overused however, they can make your code more difficult to maintain or even become a source of bugs. These rules shine a light on potentially risky features, describing when and why they should be avoided.
4
8
5
9
## Element selectors with `scoped` {#element-selectors-with-scoped}
0 commit comments