diff --git a/src/api/sfc-script-setup.md b/src/api/sfc-script-setup.md index f1e9677015..c2a04391a9 100644 --- a/src/api/sfc-script-setup.md +++ b/src/api/sfc-script-setup.md @@ -298,16 +298,20 @@ function inc() { :::warning If you have a `default` value for `defineModel` prop and you don't provide any value for this prop from the parent component, it can cause a de-synchronization between parent and child components. In the example below, the parent's `myRef` is undefined, but the child's `model` is 1: -```js -// child component: +```vue [Child.vue] + +``` -// parent component: +```vue [Parent.vue] + -```html - + ``` ::: diff --git a/src/guide/built-ins/transition.md b/src/guide/built-ins/transition.md index 9462144296..0d46248c2e 100644 --- a/src/guide/built-ins/transition.md +++ b/src/guide/built-ins/transition.md @@ -469,8 +469,7 @@ Here's a demo using the [GSAP library](https://gsap.com/) to perform the animati Transitions can be reused through Vue's component system. To create a reusable transition, we can create a component that wraps the `` component and passes down the slot content: -```vue{5} - +```vue{6} [MyTransition.vue] diff --git a/src/guide/components/provide-inject.md b/src/guide/components/provide-inject.md index 6c0addc7c2..3a5329c7e5 100644 --- a/src/guide/components/provide-inject.md +++ b/src/guide/components/provide-inject.md @@ -297,7 +297,7 @@ provide('read-only-count', readonly(count)) In order to make injections reactively linked to the provider, we need to provide a computed property using the [computed()](/api/reactivity-core#computed) function: -```js{10} +```js{12} import { computed } from 'vue' export default { @@ -327,8 +327,7 @@ So far, we have been using string injection keys in the examples. If you are wor It's recommended to export the Symbols in a dedicated file: -```js -// keys.js +```js [keys.js] export const myInjectionKey = Symbol() ``` diff --git a/src/guide/components/v-model.md b/src/guide/components/v-model.md index 2fb1341359..e1248c18f5 100644 --- a/src/guide/components/v-model.md +++ b/src/guide/components/v-model.md @@ -12,8 +12,7 @@ Starting in Vue 3.4, the recommended approach to achieve this is using the [`defineModel()`](/api/sfc-script-setup#definemodel) macro: -```vue - +```vue [Child.vue] ``` -**Parent component:** - -```js +```vue [Parent.vue] + -```html - + ``` ::: @@ -156,8 +152,7 @@ For this to actually work though, the `` component must do two thin Here's that in action: -```vue - +```vue [CustomInput.vue] @@ -243,8 +236,7 @@ const title = defineModel('title', { required: true })
Pre 3.4 Usage -```vue - +```vue [MyComponent.vue] @@ -352,8 +350,8 @@ Which can be used in the template to control the font size of all blog posts: Now let's add a button to the `` component's template: -```vue{5} - +```vue{5} [BlogPost.vue] +