Skip to content

Commit fa27c35

Browse files
Merge branch 'vuejs:main' into main
2 parents f0b7466 + bea9c1d commit fa27c35

File tree

4 files changed

+48
-102
lines changed

4 files changed

+48
-102
lines changed

.vitepress/theme/components/PreferenceSwitch.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import {
1111
1212
const route = useRoute()
1313
const show = $computed(() =>
14-
/^\/(guide|tutorial|examples)\//.test(route.path)
14+
/^\/(guide|tutorial|examples|style-guide)\//.test(route.path)
1515
)
16-
const showSFC = $computed(() => !/^\/guide/.test(route.path))
16+
const showSFC = $computed(() => !/^\/guide|style-guide/.test(route.path))
1717
1818
let isOpen = $ref(true)
1919
@@ -206,11 +206,11 @@ function useToggleFn(
206206
font-size: 11px;
207207
padding: 8px 4px;
208208
}
209-
209+
210210
.vt-switch {
211211
margin: auto;
212212
}
213-
213+
214214
.switch-link {
215215
margin-left: auto;
216216
}

src/guide/built-ins/transition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ There are six classes applied for enter / leave transitions.
9191

9292
4. `v-leave-from`: Starting state for leave. Added immediately when a leaving transition is triggered, removed after one frame.
9393

94-
5. `v-leave-active`: Active state for leave. Applied during the entire leaving phase. Added immediately when a leave transition is triggered, removed when the transition/animation finishes. This class can be used to define the duration, delay and easing curve for the leaving transition.
94+
5. `v-leave-active`: Active state for leave. Applied during the entire leaving phase. Added immediately when a leaving transition is triggered, removed when the transition/animation finishes. This class can be used to define the duration, delay and easing curve for the leaving transition.
9595

9696
6. `v-leave-to`: Ending state for leave. Added one frame after a leaving transition is triggered (at the same time `v-leave-from` is removed), removed when the transition/animation finishes.
9797

src/guide/essentials/reactivity-fundamentals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default {
101101
<div>{{ state.count }}</div>
102102
```
103103

104-
Similarly, we can declare functions that mutate reactive state in the same scope and expose it as a method alongside the state:
104+
Similarly, we can declare functions that mutate reactive state in the same scope and expose them as methods alongside the state:
105105

106106
```js{7-9,14}
107107
import { reactive } from 'vue'

src/style-guide/rules-essential.md

Lines changed: 42 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Detailed [prop definitions](/guide/components/props.html#prop-validation) have t
4343
- In development, Vue will warn you if a component is ever provided incorrectly formatted props, helping you catch potential sources of error.
4444
:::
4545

46+
<div class="options-api">
4647
<div class="style-example style-example-bad">
4748
<h3>Bad</h3>
4849

@@ -81,6 +82,47 @@ props: {
8182
}
8283
```
8384

85+
</div>
86+
</div>
87+
88+
<div class="composition-api">
89+
<div class="style-example style-example-bad">
90+
<h3>Bad</h3>
91+
92+
```js
93+
// This is only OK when prototyping
94+
const props = defineProps(['status'])
95+
```
96+
97+
</div>
98+
99+
<div class="style-example style-example-good">
100+
<h3>Good</h3>
101+
102+
```js
103+
const props = defineProps({
104+
status: String
105+
})
106+
```
107+
108+
```js
109+
// Even better!
110+
111+
const props = defineProps({
112+
status: {
113+
type: String,
114+
required: true,
115+
116+
validator: (value) => {
117+
return ['syncing', 'synced', 'version-conflict', 'error'].includes(
118+
value
119+
)
120+
}
121+
}
122+
})
123+
```
124+
125+
</div>
84126
</div>
85127

86128
## Use keyed `v-for` {#use-keyed-v-for}
@@ -339,99 +381,3 @@ Beyond the `scoped` attribute, using unique class names can help ensure that 3rd
339381
```
340382

341383
</div>
342-
343-
## Avoid exposing private functions in mixins {#avoid-exposing-private-functions-in-mixins}
344-
345-
Always use the `$_` prefix for custom private properties in a plugin, mixin, etc that should not be considered public API. Then to avoid conflicts with code by other authors, also include a named scope (e.g. `$_yourPluginName_`).
346-
347-
::: details Detailed Explanation
348-
Vue uses the `_` prefix to define its own private properties, so using the same prefix (e.g. `_update`) risks overwriting an instance property. Even if you check and Vue is not currently using a particular property name, there is no guarantee a conflict won't arise in a later version.
349-
350-
As for the `$` prefix, its purpose within the Vue ecosystem is special instance properties that are exposed to the user, so using it for _private_ properties would not be appropriate.
351-
352-
Instead, we recommend combining the two prefixes into `$_`, as a convention for user-defined private properties that guarantee no conflicts with Vue.
353-
:::
354-
355-
<div class="style-example style-example-bad">
356-
<h3>Bad</h3>
357-
358-
```js
359-
const myGreatMixin = {
360-
// ...
361-
methods: {
362-
update() {
363-
// ...
364-
}
365-
}
366-
}
367-
```
368-
369-
```js
370-
const myGreatMixin = {
371-
// ...
372-
methods: {
373-
_update() {
374-
// ...
375-
}
376-
}
377-
}
378-
```
379-
380-
```js
381-
const myGreatMixin = {
382-
// ...
383-
methods: {
384-
$update() {
385-
// ...
386-
}
387-
}
388-
}
389-
```
390-
391-
```js
392-
const myGreatMixin = {
393-
// ...
394-
methods: {
395-
$_update() {
396-
// ...
397-
}
398-
}
399-
}
400-
```
401-
402-
</div>
403-
404-
<div class="style-example style-example-good">
405-
<h3>Good</h3>
406-
407-
```js
408-
const myGreatMixin = {
409-
// ...
410-
methods: {
411-
$_myGreatMixin_update() {
412-
// ...
413-
}
414-
}
415-
}
416-
```
417-
418-
```js
419-
// Even better!
420-
const myGreatMixin = {
421-
// ...
422-
methods: {
423-
publicMethod() {
424-
// ...
425-
myPrivateFunction()
426-
}
427-
}
428-
}
429-
430-
function myPrivateFunction() {
431-
// ...
432-
}
433-
434-
export default myGreatMixin
435-
```
436-
437-
</div>

0 commit comments

Comments
 (0)