Skip to content

Commit 538ab4d

Browse files
committed
docs: update study log
1 parent 2918402 commit 538ab4d

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

English/Vue/Essentials/Components-Basics.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,41 @@ Components allow us to split the UI into independent and reusable pieces, and th
33

44
This is very similar to how we nest native HTML elements, but Vue implements its own component model that allows us to encapsulate custom content and logic in each component. Vue also plays nicely with native Web Components. If you are curious about the relationship between Vue Components and native Web Components, read more here.\
55
encapsulate [/ɪnˈkæpsjuleɪt/] 封装
6+
7+
## Defining a Component​
8+
When using a build step, we typically define each Vue component in a dedicated file using the `.vue` extension - known as a Single-File Component (SFC for short):
9+
10+
```vue
11+
<script>
12+
export default {
13+
data() {
14+
return {
15+
count: 0
16+
}
17+
}
18+
}
19+
</script>
20+
21+
<template>
22+
<button @click="count++">You clicked me {{ count }} times.</button>
23+
</template>
24+
```
25+
When not using a build step, a Vue component can be defined as a plain JavaScript object containing Vue-specific options:
26+
27+
```js
28+
export default {
29+
data() {
30+
return {
31+
count: 0
32+
}
33+
},
34+
template: `
35+
<button @click="count++">
36+
You clicked me {{ count }} times.
37+
</button>`
38+
}
39+
```
40+
The template is inlined as a JavaScript string here, which Vue will compile on the fly. You can also use an ID selector pointing to an element (usually native `<template>` elements) - Vue will use its content as the template source.\
41+
on the fly 立即,立刻
42+
43+
The example above defines a single component and exports it as the default export of a `.js` file, but you can use named exports to export multiple components from the same file.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
# 日志
66

7+
## 2026.5.13
8+
[Vue doc Components Basics](./English/Vue/Essentials/Components-Basics.md)
9+
710
## 2026.5.12
811
[Vue doc Components Basics](./English/Vue/Essentials/Components-Basics.md)
912

0 commit comments

Comments
 (0)