diff --git a/src/.vuepress/components/conditional-1.vue b/src/.vuepress/components/conditional-1.vue
new file mode 100644
index 0000000000..1179e89277
--- /dev/null
+++ b/src/.vuepress/components/conditional-1.vue
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
diff --git a/src/.vuepress/components/conditional-2.vue b/src/.vuepress/components/conditional-2.vue
new file mode 100644
index 0000000000..2d5c72b2f7
--- /dev/null
+++ b/src/.vuepress/components/conditional-2.vue
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
diff --git a/src/.vuepress/components/list-1.vue b/src/.vuepress/components/list-1.vue
new file mode 100644
index 0000000000..32b9f49884
--- /dev/null
+++ b/src/.vuepress/components/list-1.vue
@@ -0,0 +1,17 @@
+
+
+
+ {{ item.message }}
+
+
+
+
+
diff --git a/src/.vuepress/components/list-2.vue b/src/.vuepress/components/list-2.vue
new file mode 100644
index 0000000000..1230fa0b27
--- /dev/null
+++ b/src/.vuepress/components/list-2.vue
@@ -0,0 +1,18 @@
+
+
+
+ {{ parentMessage }} - {{ index }} - {{ item.message }}
+
+
+
+
+
diff --git a/src/.vuepress/components/list-3.vue b/src/.vuepress/components/list-3.vue
new file mode 100644
index 0000000000..42e3e352f8
--- /dev/null
+++ b/src/.vuepress/components/list-3.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
diff --git a/src/.vuepress/components/list-4.vue b/src/.vuepress/components/list-4.vue
new file mode 100644
index 0000000000..f0d17949a5
--- /dev/null
+++ b/src/.vuepress/components/list-4.vue
@@ -0,0 +1,21 @@
+
+
+ {{ name }}: {{ value }}
+
+
+
+
+
+
diff --git a/src/.vuepress/components/list-5.vue b/src/.vuepress/components/list-5.vue
new file mode 100644
index 0000000000..bd6a7f0455
--- /dev/null
+++ b/src/.vuepress/components/list-5.vue
@@ -0,0 +1,23 @@
+
+
+
+ {{ index }}. {{ name }}: {{ value }}
+
+
+
+
+
+
+
diff --git a/src/.vuepress/components/list-6.vue b/src/.vuepress/components/list-6.vue
new file mode 100644
index 0000000000..91d94f7471
--- /dev/null
+++ b/src/.vuepress/components/list-6.vue
@@ -0,0 +1,5 @@
+
+
+ {{ n }}
+
+
diff --git a/src/.vuepress/components/list-7.vue b/src/.vuepress/components/list-7.vue
new file mode 100644
index 0000000000..6857442ab6
--- /dev/null
+++ b/src/.vuepress/components/list-7.vue
@@ -0,0 +1,53 @@
+
+
+
+
+
+ {{ todo.title }}
+ Remove
+
+
+
+
+
+
diff --git a/src/.vuepress/config.js b/src/.vuepress/config.js
index 89833d5e9a..a4badbccc2 100644
--- a/src/.vuepress/config.js
+++ b/src/.vuepress/config.js
@@ -36,8 +36,8 @@ module.exports = {
'template-syntax',
// 'computed',
// 'class-and-style',
- // 'conditional',
- // 'list'
+ 'conditional',
+ 'list'
// 'events'
]
}
diff --git a/src/guide/conditional.md b/src/guide/conditional.md
new file mode 100644
index 0000000000..bc8eaa040d
--- /dev/null
+++ b/src/guide/conditional.md
@@ -0,0 +1,138 @@
+# Conditional Rendering
+
+
+
+## `v-if`
+
+The directive `v-if` is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy value.
+
+```html
+Vue is awesome!
+```
+
+It is also possible to add an "else block" with `v-else`:
+
+```html
+Vue is awesome!
+Oh no 😢
+```
+
+### Conditional Groups with `v-if` on ``
+
+Because `v-if` is a directive, it has to be attached to a single element. But what if we want to toggle more than one element? In this case we can use `v-if` on a `` element, which serves as an invisible wrapper. The final rendered result will not include the `` element.
+
+```html
+
+ Title
+ Paragraph 1
+ Paragraph 2
+
+```
+
+### `v-else`
+
+You can use the `v-else` directive to indicate an "else block" for `v-if`:
+
+```html
+
+ Now you see me
+
+
+ Now you don't
+
+```
+
+A `v-else` element must immediately follow a `v-if` or a `v-else-if` element - otherwise it will not be recognized.
+
+### `v-else-if`
+
+The `v-else-if`, as the name suggests, serves as an "else if block" for `v-if`. It can also be chained multiple times:
+
+```html
+
+ A
+
+
+ B
+
+
+ C
+
+
+ Not A/B/C
+
+```
+
+Similar to `v-else`, a `v-else-if` element must immediately follow a `v-if` or a `v-else-if` element.
+
+### Controlling Reusable Elements with `key`
+
+Vue tries to render elements as efficiently as possible, often re-using them instead of rendering from scratch. Beyond helping make Vue very fast, this can have some useful advantages. For example, if you allow users to toggle between multiple login types:
+
+```html
+
+ Username
+
+
+
+ Email
+
+
+```
+
+Then switching the `loginType` in the code above will not erase what the user has already entered. Since both templates use the same elements, the ` ` is not replaced - just its `placeholder`.
+
+Check it out for yourself by entering some text in the input, then pressing the toggle button:
+
+
+
+This isn't always desirable though, so Vue offers a way for you to say, "These two elements are completely separate - don't re-use them." Add a `key` attribute with unique values:
+
+```html
+
+ Username
+
+
+
+ Email
+
+
+```
+
+Now those inputs will be rendered from scratch each time you toggle. See for yourself:
+
+
+
+Note that the `` elements are still efficiently re-used, because they don't have `key` attributes.
+
+## `v-show`
+
+Another option for conditionally displaying an element is the `v-show` directive. The usage is largely the same:
+
+```html
+Hello!
+```
+
+The difference is that an element with `v-show` will always be rendered and remain in the DOM; `v-show` only toggles the `display` CSS property of the element.
+
+::: tip
+Note that `v-show` doesn't support the ::: v-pre `` ::: element, nor does it work with `v-else`.
+:::
+
+## `v-if` vs `v-show`
+
+`v-if` is "real" conditional rendering because it ensures that event listeners and child components inside the conditional block are properly destroyed and re-created during toggles.
+
+`v-if` is also **lazy**: if the condition is false on initial render, it will not do anything - the conditional block won't be rendered until the condition becomes true for the first time.
+
+In comparison, `v-show` is much simpler - the element is always rendered regardless of initial condition, with CSS-based toggling.
+
+Generally speaking, `v-if` has higher toggle costs while `v-show` has higher initial render costs. So prefer `v-show` if you need to toggle something very often, and prefer `v-if` if the condition is unlikely to change at runtime.
+
+## `v-if` with `v-for`
+
+::: tip
+Using `v-if` and `v-for` together is **not recommended**. See the [style guide](TODO:/v2/style-guide/#Avoid-v-if-with-v-for-essential) for further information.
+:::
+
+When used together with `v-if`, `v-for` has a higher priority than `v-if`. See the [list rendering guide](list#v-for-with-v-if) for details.
diff --git a/src/guide/list.md b/src/guide/list.md
new file mode 100644
index 0000000000..8a6449620b
--- /dev/null
+++ b/src/guide/list.md
@@ -0,0 +1,370 @@
+# List Rendering
+
+
+
+## Mapping an Array to Elements with `v-for`
+
+We can use the `v-for` directive to render a list of items based on an array. The `v-for` directive requires a special syntax in the form of `item in items`, where `items` is the source data array and `item` is an **alias** for the array element being iterated on:
+
+```html
+
+
+ {{ item.message }}
+
+
+```
+
+```js
+Vue.createApp().mount(
+ {
+ data() {
+ return {
+ items: [{ message: 'Foo' }, { message: 'Bar' }]
+ }
+ }
+ },
+ '#example-1'
+)
+```
+
+Result:
+
+
+
+Inside `v-for` blocks we have full access to parent scope properties. `v-for` also supports an optional second argument for the index of the current item.
+
+```html
+
+
+ {{ parentMessage }} - {{ index }} - {{ item.message }}
+
+
+```
+
+```js
+Vue.createApp().mount(
+ {
+ data() {
+ return {
+ parentMessage: 'Parent',
+ items: [{ message: 'Foo' }, { message: 'Bar' }]
+ }
+ }
+ },
+ '#example-2'
+)
+```
+
+Result:
+
+
+
+You can also use `of` as the delimiter instead of `in`, so that it is closer to JavaScript's syntax for iterators:
+
+```html
+
+```
+
+## `v-for` with an Object
+
+You can also use `v-for` to iterate through the properties of an object.
+
+```html
+
+```
+
+```js
+Vue.createApp().mount(
+ {
+ data() {
+ return {
+ myObject: {
+ title: 'How to do lists in Vue',
+ author: 'Jane Doe',
+ publishedAt: '2016-04-10'
+ }
+ }
+ }
+ },
+ '#v-for-object'
+)
+```
+
+Result:
+
+
+
+You can also provide a second argument for the property's name (a.k.a. key):
+
+```html
+
+ {{ name }}: {{ value }}
+
+```
+
+
+
+And another for the index:
+
+```html
+
+ {{ index }}. {{ name }}: {{ value }}
+
+```
+
+
+
+:::tip
+When iterating over an object, the order is based on the enumeration order of `Object.keys()`, which is **not** guaranteed to be consistent across JavaScript engine implementations.
+:::
+
+## Maintaining State
+
+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. This is similar to the behavior of `track-by="$index"` in Vue 1.x.
+
+This default mode is efficient, but **only suitable when your list render output does not rely on child component state or temporary DOM state (e.g. form input values)**.
+
+To give Vue a hint so that it can track each node's identity, and thus reuse and reorder existing elements, you need to provide a unique `key` attribute for each item:
+
+```html
+
+
+
+```
+
+It is recommended to provide a `key` attribute with `v-for` whenever possible, unless the iterated DOM content is simple, or you are intentionally relying on the default behavior for performance gains.
+
+Since it's a generic mechanism for Vue to identify nodes, the `key` also has other uses that are not specifically tied to `v-for`, as we will see later in the guide.
+
+:::tip
+Don't use non-primitive values like objects and arrays as `v-for` keys. Use string or numeric values instead.
+:::
+
+For detailed usage of the `key` attribute, please see the [`key` API documentation](TODO:https://vuejs.org/v2/api/#key).
+
+## Array Change Detection
+
+### Mutation Methods
+
+Vue wraps an observed array's mutation methods so they will also trigger view updates. The wrapped methods are:
+
+- `push()`
+- `pop()`
+- `shift()`
+- `unshift()`
+- `splice()`
+- `sort()`
+- `reverse()`
+
+You can open the console and play with the previous examples' `items` array by calling their mutation methods. For example: `example1.items.push({ message: 'Baz' })`.
+
+### Replacing an Array
+
+Mutation methods, as the name suggests, mutate the original array they are called on. In comparison, there are also non-mutating methods, e.g. `filter()`, `concat()` and `slice()`, which do not mutate the original array but **always return a new array**. When working with non-mutating methods, you can replace the old array with the new one:
+
+```js
+example1.items = example1.items.filter(item => return item.message.match(/Foo/))
+```
+
+You might think this will cause Vue to throw away the existing DOM and re-render the entire list - luckily, that is not the case. Vue implements some smart heuristics to maximize DOM element reuse, so replacing an array with another array containing overlapping objects is a very efficient operation.
+
+## Displaying Filtered/Sorted Results
+
+Sometimes we want to display a filtered or sorted version of an array without actually mutating or resetting the original data. In this case, you can create a computed property that returns the filtered or sorted array.
+
+For example:
+
+```html
+{{ n }}
+```
+
+```js
+data() {
+ return {
+ numbers: [ 1, 2, 3, 4, 5 ]
+ }
+},
+computed: {
+ evenNumbers() {
+ return this.numbers.filter(number => number % 2 === 0)
+ }
+}
+```
+
+In situations where computed properties are not feasible (e.g. inside nested `v-for` loops), you can use a method:
+
+```html
+
+```
+
+```js
+data() {
+ return {
+ sets: [[ 1, 2, 3, 4, 5 ], [6, 7, 8, 9, 10]]
+ }
+},
+methods: {
+ even(numbers) {
+ return numbers.filter(number => number % 2 === 0)
+ }
+}
+```
+
+## `v-for` with a Range
+
+`v-for` can also take an integer. In this case it will repeat the template that many times.
+
+```html
+
+ {{ n }}
+
+```
+
+Result:
+
+
+
+## `v-for` on a ``
+
+Similar to template `v-if`, you can also use a :::v-pre``::: tag with `v-for` to render a block of multiple elements. For example:
+
+```html
+
+```
+
+## `v-for` with `v-if`
+
+:::tip
+Note that it's **not** recommended to use `v-if` and `v-for` together. Refer to [style guide](/v2/style-guide/#Avoid-v-if-with-v-for-essential) for details.
+:::
+
+When they exist on the same node, `v-for` has a higher priority than `v-if`. That means the `v-if` will be run on each iteration of the loop separately. This can be useful when you want to render nodes for only _some_ items, like below:
+
+```html
+
+ {{ todo }}
+
+```
+
+The above only renders the todos that are not complete.
+
+If instead, your intent is to conditionally skip execution of the loop, you can place the `v-if` on a wrapper element (or [``](conditional#conditional-groups-with-v-if-on-lt-template-gt)). For example:
+
+```html
+
+No todos left!
+```
+
+## `v-for` with a Component
+
+> This section assumes knowledge of [Components](TODO:components.html). Feel free to skip it and come back later.
+
+You can directly use `v-for` on a custom component, like any normal element:
+
+```html
+
+```
+
+However, this won't automatically pass any data to the component, because components have isolated scopes of their own. In order to pass the iterated data into the component, we should also use props:
+
+```html
+
+```
+
+The reason for not automatically injecting `item` into the component is because that makes the component tightly coupled to how `v-for` works. Being explicit about where its data comes from makes the component reusable in other situations.
+
+Here's a complete example of a simple todo list:
+
+```html
+
+```
+
+```js
+const TodoItem = {
+ template: `
+
+ {{ title }}
+ Remove
+
+ `,
+ props: ['title']
+}
+
+Vue.createApp().mount(
+ {
+ components: {
+ 'todo-item': TodoItem
+ },
+ data() {
+ return {
+ newTodoText: '',
+ todos: [
+ {
+ id: 1,
+ title: 'Do the dishes'
+ },
+ {
+ id: 2,
+ title: 'Take out the trash'
+ },
+ {
+ id: 3,
+ title: 'Mow the lawn'
+ }
+ ],
+ nextTodoId: 4
+ }
+ },
+ methods: {
+ addNewTodo() {
+ this.todos.push({
+ id: this.nextTodoId++,
+ title: this.newTodoText
+ })
+ this.newTodoText = ''
+ }
+ }
+ },
+ '#todo-list-example'
+)
+```
+
+