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/api/directives.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -246,8 +246,8 @@
246
246
-**Modifiers:**
247
247
248
248
-`.camel` - transform the kebab-case attribute name into camelCase.
249
-
-`.prop` - force a binding to be set as DOM property. <Badgetext="3.2+"/>
250
-
-`.attr` - force a binding to be set as DOM attribute. <Badgetext="3.2+"/>
249
+
-`.prop` - force a binding to be set as a DOM property. <Badgetext="3.2+"/>
250
+
-`.attr` - force a binding to be set as a DOM attribute. <Badgetext="3.2+"/>
251
251
252
252
-**Usage:**
253
253
@@ -299,7 +299,7 @@
299
299
<svg><a:xlink:special="foo"></a></svg>
300
300
```
301
301
302
-
When setting a binding on an element, Vue by default checks whether the element has the key defined as a property using an `in` operator check. If the property is defined, Vue will set the value as DOM property instead of an attribute. This should work in most cases, but you can override this behavior by explicitly using `.prop` or `.attr` modifiers. This is sometimes necessary especially when [working with custom elements](/guide/web-components.html#passing-dom-properties).
302
+
When setting a binding on an element, Vue by default checks whether the element has the key defined as a property using an `in` operator check. If the property is defined, Vue will set the value as a DOM property instead of an attribute. This should work in most cases, but you can override this behavior by explicitly using `.prop` or `.attr` modifiers. This is sometimes necessary, especially when [working with custom elements](/guide/web-components.html#passing-dom-properties).
303
303
304
304
The `.prop` modifier also has a dedicated shorthand, `.`:
305
305
@@ -481,15 +481,15 @@
481
481
</div>
482
482
```
483
483
484
-
When the component re-renders, if both `valueA` and `valueB`remains the same, all updates for this `<div>` and its children will be skipped. In fact, even the Virtual DOM vnode creation will also be skipped since the memoized copy of the sub-tree can be reused.
484
+
When the component re-renders, if both `valueA` and `valueB`remain the same, all updates for this `<div>` and its children will be skipped. In fact, even the Virtual DOM VNode creation will also be skipped since the memoized copy of the sub-tree can be reused.
485
485
486
486
It is important to specify the memoization array correctly, otherwise we may skip updates that should indeed be applied.
487
487
488
488
This directive is provided solely for micro optimizations in performance-critical scenarios and should be rarely needed. The most common case where this may prove helpful is when rendering large `v-for` lists (where `length > 1000`):
489
489
490
490
```html
491
491
<divv-for="item in list":key="item.id"v-memo="[item.id === selected]">
For more details on building Web Components with Vue, especially with Single File Components, see [Vue and Web Components](/guide/web-components#building-custom-elements-with-vue).
273
+
For more details on building Web Components with Vue, especially with Single File Components, see [Vue and Web Components](/guide/web-components.html#building-custom-elements-with-vue).
The code inside are compiled as the content of the component's `setup()` function. This means unlike normal `<script>`, which only executes once when the component is first imported, code inside `<script setup>` will **execute every time an instance of the component is created**.
24
+
The code inside is compiled as the content of the component's `setup()` function. This means that unlike normal `<script>`, which only executes once when the component is first imported, code inside `<script setup>` will **execute every time an instance of the component is created**.
25
25
26
-
### Toplevel bindings are exposed to template
26
+
### Top-level bindings are exposed to template
27
27
28
28
When using `<script setup>`, any top-level bindings (including variables, function declarations, and imports) declared inside `<script setup>` are directly usable in the template:
29
29
@@ -57,7 +57,7 @@ import { capitalize } from './helpers'
57
57
58
58
## Reactivity
59
59
60
-
Reactive state needs to be explicitly created using [Reactivity APIs](/api/basic-reactivity.html). Similar to returned values from the`setup()`functions, refs are automatically unwrapped when referenced in templates:
60
+
Reactive state needs to be explicitly created using [Reactivity APIs](/api/basic-reactivity.html). Similar to values returned from a`setup()`function, refs are automatically unwrapped when referenced in templates:
61
61
62
62
```vue
63
63
<script setup>
@@ -85,7 +85,7 @@ import MyComponent from './MyComponent.vue'
85
85
</template>
86
86
```
87
87
88
-
Think of `MyComponent` as being referenced as a variable. If you have used JSX before, the mental model is similar here. The kebab-case equivalent `<my-component>` also works in the template - however PascalCase component tags are strongly recommended for consistency. It also helps differentiating from native custom elements.
88
+
Think of `MyComponent` as being referenced as a variable. If you have used JSX, the mental model is similar here. The kebab-case equivalent `<my-component>` also works in the template - however PascalCase component tags are strongly recommended for consistency. It also helps differentiating from native custom elements.
89
89
90
90
### Dynamic Components
91
91
@@ -107,7 +107,7 @@ Note how the components can be used as variables in a ternary expression.
107
107
108
108
### Recursive Components
109
109
110
-
SFCs can implicitly refer to itself via its filename. E.g. a file named `FooBar.vue` can refer to itself as `<FooBar/>` in its template.
110
+
An SFC can implicitly refer to itself via its filename. E.g. a file named `FooBar.vue` can refer to itself as `<FooBar/>` in its template.
111
111
112
112
Note this has lower priority than imported components. If you have a named import that conflicts with the component's inferred name, you can alias the import:
113
113
@@ -177,7 +177,7 @@ const attrs = useAttrs()
177
177
178
178
## Usage alongside normal `<script>`
179
179
180
-
`<script setup>` can be used alongside normal `<script>`. A normal `<script>`maybe needed in cases where we need to:
180
+
`<script setup>` can be used alongside normal `<script>`. A normal `<script>`may be needed in cases where we need to:
181
181
182
182
- Declare options that cannot be expressed in `<script setup>`, for example `inheritAttrs` or custom options enabled via plugins.
183
183
- Declaring named exports.
@@ -200,9 +200,9 @@ export default {
200
200
</script>
201
201
```
202
202
203
-
## Toplevel await
203
+
## Top-level `await`
204
204
205
-
Toplevel `await` can be used inside `<script setup>`. The resulting code will be compiled as `async setup()`:
205
+
Top-level `await` can be used inside `<script setup>`. The resulting code will be compiled as `async setup()`:
206
206
207
207
```vue
208
208
<script setup>
@@ -232,7 +232,7 @@ const emit = defineEmits<{
232
232
233
233
-`defineProps` or `defineEmits` can only use either runtime declaration OR type declaration. Using both at the same time will result in a compile error.
234
234
235
-
- When using type declaration, equivalent runtime declaration is automatically generated from static analysis to remove the need of double declaration and still ensure correct runtime behavior.
235
+
- When using type declaration, the equivalent runtime declaration is automatically generated from static analysis to remove the need for double declaration and still ensure correct runtime behavior.
236
236
237
237
- In dev mode, the compiler will try to infer corresponding runtime validation from the types. For example here `foo: String` is inferred from the `foo: string` type. If the type is a reference to an imported type, the inferred result will be `foo: null` (equal to `any` type) since the compiler does not have information of external files.
238
238
@@ -243,7 +243,7 @@ const emit = defineEmits<{
243
243
- As of now, the type declaration argument must be one of the following to ensure correct static analysis:
244
244
245
245
- A type literal
246
-
- A reference to a an interface or a type literal in the same file
246
+
- A reference to an interface or a type literal in the same file
247
247
248
248
Currently complex types and type imports from other files are not supported. It is theoretically possible to support type imports in the future.
249
249
@@ -265,4 +265,4 @@ This will be compiled to equivalent runtime props `default` options. In addition
265
265
266
266
## Restriction: No Src Imports
267
267
268
-
Due to the difference in module execution semantics, code inside `<script setup>` relies on the context of an SFC. When moved into external `.js` or `.ts` files, it may lead to confusions for both developers and tools. Therefore, **`<script setup>`** cannot be used with the `src` attribute.
268
+
Due to the difference in module execution semantics, code inside `<script setup>` relies on the context of an SFC. When moved into external `.js` or `.ts` files, it may lead to confusion for both developers and tools. Therefore, **`<script setup>`** cannot be used with the `src` attribute.
Copy file name to clipboardExpand all lines: src/api/sfc-spec.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -60,10 +60,10 @@ export default {
60
60
61
61
### Custom Blocks
62
62
63
-
Additional custom blocks can be included in a `*.vue` file for any projectspecific needs, for example a `<docs>` block. Some real-world examples of custom blocks include:
63
+
Additional custom blocks can be included in a `*.vue` file for any project-specific needs, for example a `<docs>` block. Some real-world examples of custom blocks include:
Handling of Custom Blocks will depend on tooling - if you want to build your own custom block integrations, see [SFC Tooling](/api/sfc-tooling.html#custom-blocks-integration) for more details.
@@ -117,7 +117,7 @@ If you prefer splitting up your `*.vue` components into multiple files, you can
117
117
<script src="./script.js"></script>
118
118
```
119
119
120
-
Beware that `src` imports follow the same path resolution rules to webpack module requests, which means:
120
+
Beware that `src` imports follow the same path resolution rules as webpack module requests, which means:
121
121
122
122
- Relative paths need to start with `./`
123
123
- You can import resources from npm dependencies:
@@ -136,4 +136,4 @@ Beware that `src` imports follow the same path resolution rules to webpack modul
136
136
137
137
## Comments
138
138
139
-
Inside each block you shall use the comment syntax of the language being used (HTML, CSS, JavaScript, Jade, etc). For top-level comments, use HTML comment syntax: `<!-- comment contents here -->`
139
+
Inside each block you shall use the comment syntax of the language being used (HTML, CSS, JavaScript, Pug, etc.). For top-level comments, use HTML comment syntax: `<!-- comment contents here -->`
Copy file name to clipboardExpand all lines: src/api/sfc-style.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -132,15 +132,15 @@ Refer to the [CSS Modules spec](https://github.com/css-modules/css-modules) for
132
132
133
133
You can customize the property key of the injected classes object by giving the `module` attribute a value:
134
134
135
-
```html
135
+
```vue
136
136
<template>
137
137
<p :class="classes.red">red</p>
138
138
</template>
139
139
140
140
<style module="classes">
141
-
.red {
142
-
color: red;
143
-
}
141
+
.red {
142
+
color: red;
143
+
}
144
144
</style>
145
145
```
146
146
@@ -190,4 +190,4 @@ p {
190
190
</style>
191
191
```
192
192
193
-
The actual value will be compiled into a hashed CSS custom property so the CSS is still static. The custom property will be applied to component's root element via inline styles and reactively updated if the source value changes.
193
+
The actual value will be compiled into a hashed CSS custom property, so the CSS is still static. The custom property will be applied to the component's root element via inline styles and reactively updated if the source value changes.
Copy file name to clipboardExpand all lines: src/api/sfc-tooling.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -17,16 +17,16 @@ It is also recommended to use these online playgrounds to provide reproductions
17
17
18
18
### Vite
19
19
20
-
[Vite](https://vitejs.dev/) is a lightweight and fast build tool with first-class Vue SFC support. It is created by Evan You who is also the author of Vue itself! To get started with Vite + Vue, simply run:
20
+
[Vite](https://vitejs.dev/) is a lightweight and fast build tool with first-class Vue SFC support. It is created by Evan You, who is also the author of Vue itself! To get started with Vite + Vue, simply run:
21
21
22
22
```sh
23
23
npm init vite@latest
24
24
```
25
25
26
-
Then select the Vue template and follow instructions.
26
+
Then select the Vue template and follow the instructions.
27
27
28
28
- To learn more about Vite, check out the [Vite docs](https://vitejs.dev/guide/).
29
-
- To configure Vuespecific behavior in a Vite project, for example passing options to the Vue compiler, check out docs for [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue#readme).
29
+
- To configure Vue-specific behavior in a Vite project, for example passing options to the Vue compiler, check out the docs for [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue#readme).
30
30
31
31
The [SFC Playground](https://sfc.vuejs.org/) also supports downloading the files as a Vite project.
32
32
@@ -71,7 +71,7 @@ Custom blocks are compiled into imports to the same Vue file with different requ
71
71
72
72
- If using Vue CLI or plain webpack, a webpack loader should be configured to transform the matched blocks. [[Example](https://vue-loader.vuejs.org/guide/custom-blocks.html#custom-blocks)]
Copy file name to clipboardExpand all lines: src/guide/introduction.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -314,7 +314,7 @@ In a large application, it is necessary to divide the whole app into components
314
314
315
315
### Relation to Custom Elements
316
316
317
-
You may have noticed that Vue components look similar to **Custom Elements**, which are part of the [Web Components Spec](https://www.w3.org/wiki/WebComponents/). Indeed, parts of Vue's component design (for example the slot API) was influenced by the spec before it was natively implemented in browsers.
317
+
You may have noticed that Vue components look similar to **Custom Elements**, which are part of the [Web Components Spec](https://www.w3.org/wiki/WebComponents/). Indeed, parts of Vue's component design (for example the slot API) were influenced by the spec before it was natively implemented in browsers.
318
318
319
319
The main difference is that Vue's component model is designed as a part of a coherent framework that provides many additional features necessary for building non-trivial applications, for example reactive templating and state management - both of which the spec does not cover.
Copy file name to clipboardExpand all lines: src/guide/single-file-component.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -73,13 +73,13 @@ SFC is a defining feature of Vue as a framework, and is the recommended approach
73
73
- Static Site Generation (SSG)
74
74
- Any non-trivial frontends where a build step can be justified for better development experience (DX).
75
75
76
-
That said, we do realize there are scenarios where SFCs can feel like an overkill. This is why Vue can still be used via plain JavaScript without a build step. If you are just looking for enhancing largely static HTML with light interactions, you can also check out [petite-vue](https://github.com/vuejs/petite-vue), a 5kb subset of Vue optimized for progressive enhancement.
76
+
That said, we do realize there are scenarios where SFCs can feel like overkill. This is why Vue can still be used via plain JavaScript without a build step. If you are just looking for enhancing largely static HTML with light interactions, you can also check out [petite-vue](https://github.com/vuejs/petite-vue), a 5kb subset of Vue optimized for progressive enhancement.
77
77
78
78
## What About Separation of Concerns?
79
79
80
80
Some users coming from a traditional web development background may have the concern that SFCs are mixing different concerns in the same place - which HTML/CSS/JS were supposed to separate!
81
81
82
-
To answer this question, it is important for us to agree that **separation of concerns is not equal to separation of file types.** The ultimate goal of engieerning principles is to improve maintainability of codebases. Separation of concerns, when applied dogmatically as separation of file types, does not help us reach that goal in the context of increasingly complex frontend applications.
82
+
To answer this question, it is important for us to agree that **separation of concerns is not equal to separation of file types.** The ultimate goal of engineering principles is to improve maintainability of codebases. Separation of concerns, when applied dogmatically as separation of file types, does not help us reach that goal in the context of increasingly complex frontend applications.
83
83
84
84
In modern UI development, we have found that instead of dividing the codebase into three huge layers that interweave with one another, it makes much more sense to divide them into loosely-coupled components and compose them. Inside a component, its template, logic, and styles are inherently coupled, and collocating them actually makes the component more cohesive and maintainable.
0 commit comments