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
Copy file name to clipboardExpand all lines: src/tutorial/src/step-1/description.md
+16-3
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,25 @@
2
2
3
3
Welcome to the Vue tutorial!
4
4
5
-
The goal of this tutorial is to quickly give you an experience of what it feels like to work with Vue, right in the browser. It does **not** aim to be comprehensive, so after you complete it, make sure to also read the <atarget="_blank"href="/guide/introduction.html">Guide</a> which covers each topic in more details.
5
+
The goal of this tutorial is to quickly give you an experience of what it feels like to work with Vue, right in the browser. It does not aim to be comprehensive, and you don't need to understand everything before moving on. However, after you complete it, make sure to also read the <atarget="_blank"href="/guide/introduction.html">Guide</a> which covers each topic in more details.
6
6
7
-
Vue offers two API styles: Options API and Composition API. This tutorial is designed to work for both - you can choose your preferred style using the **API Preference** switches at the top. <atarget="_blank"href="/guide/introduction.html#api-styles">Learn more about API styles</a>.
7
+
## Prerequisites
8
8
9
-
You can also switch between SFC-mode or HTML-mode. The former will show code examples in <atarget="_blank"href="/guide/introduction.html#single-file-components">Single-File Component</a> (SFC) format, which is what most developers use when they use Vue with a build step. HTML-mode shows usage without a build step.
9
+
The tutorial assumes basic familiarity with HTML, CSS and JavaScript. If you are totally new to front development, it might not be the best idea to jump right into a framework as your first step - grasp the basics then come back! Prior experience with other frameworks helps, but is not required.
10
+
11
+
## How to Use This Tutorial
10
12
11
13
You can edit the code <spanclass="wide">on the right</span><spanclass="narrow">below</span> and see the result update instantly. Each step will introduce a core feature of Vue, and you will be expected to complete the code to get the demo working. If you get stuck, you will have a "Show me!" button that reveals the working code for you. Try not to rely on it too much - you'll learn faster by figuring things out on your own.
12
14
15
+
If you are an experienced developer coming from Vue 2 or other frameworks, there are a few settings you can tweak to make the best use of this tutorial. If you are a beginner, it's recommended to go with the defaults.
16
+
17
+
<details>
18
+
<summary>Tutorial Setting Details</summary>
19
+
20
+
- Vue offers two API styles: Options API and Composition API. This tutorial is designed to work for both - you can choose your preferred style using the **API Preference** switches at the top. <atarget="_blank"href="/guide/introduction.html#api-styles">Learn more about API styles</a>.
21
+
22
+
- You can also switch between SFC-mode or HTML-mode. The former will show code examples in <atarget="_blank"href="/guide/introduction.html#single-file-components">Single-File Component</a> (SFC) format, which is what most developers use when they use Vue with a build step. HTML-mode shows usage without a build step.
Copy file name to clipboardExpand all lines: src/tutorial/src/step-2/description.md
+14-6
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,16 @@
1
1
# Declarative Rendering
2
2
3
-
The core feature of Vue is **declarative rendering**: using a template syntax that extends HTML, we can keep the HTML view in sync with the JavaScript state, automatically.
3
+
<divclass="sfc">
4
+
5
+
What you see in the editor is a Vue Single File Component (SFC). An SFC is a reusable self-contained block of code that encapsulates HTML, CSS and JavaScript that belong together, written inside a `.vue` file.
6
+
7
+
</div>
8
+
9
+
The core feature of Vue is **declarative rendering**: using a template syntax that extends HTML, we can describe how the HTML should look like based on JavaScript state. When the state changes, the HTML updates automatically.
4
10
5
11
<divclass="composition-api">
6
12
7
-
We can declare reactive state using `reactive()`. Objects created from `reactive()` are proxies that work just like normal objects:
13
+
State that can trigger updates when changed are considered **reactive**. We can declare reactive state using Vue's `reactive()` API. Objects created from `reactive()` are JavaScript [Proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) that work just like normal objects:
8
14
9
15
```js
10
16
import { reactive } from'vue'
@@ -32,13 +38,13 @@ Details on `reactive()` and `ref()` are discussed in <a target="_blank" href="/g
32
38
33
39
<divclass="sfc">
34
40
35
-
Variables declared in the `<script setup>` block can be used directly in the template. This is how we can render dynamic text based on the value of the `state` object and `message` ref, using mustaches syntax:
41
+
Reactive state declared in the component's`<script setup>` block can be used directly in the template. This is how we can render dynamic text based on the value of the `state` object and `message` ref, using mustaches syntax:
36
42
37
43
</div>
38
44
39
45
<divclass="html">
40
46
41
-
A component's state should be declared inside its `setup()` function, and returned using an object:
47
+
The object being passed to `createApp()` is a Vue component. A component's state should be declared inside its `setup()` function, and returned using an object:
42
48
43
49
```js{2,5}
44
50
setup() {
@@ -51,7 +57,7 @@ setup() {
51
57
}
52
58
```
53
59
54
-
Properties in the returned object will be exposed to the template. This is how we can render dynamic text based on the value of `message`, using mustaches syntax:
60
+
Properties in the returned object will be made available in the template. This is how we can render dynamic text based on the value of `message`, using mustaches syntax:
55
61
56
62
</div>
57
63
@@ -66,7 +72,9 @@ Notice how we did not need to use `.value` when accessing the `message` ref in t
66
72
67
73
<divclass="options-api">
68
74
69
-
We can declare reactive state using the `data` option, which should be a function that returns an object:
75
+
State that can trigger updates when changed are considered **reactive**. In Vue, reactive state is held in components. In the example code, the object being passed to `createApp()` is a component.
76
+
77
+
We can declare reactive state using the `data` component option, which should be a function that returns an object:
0 commit comments