From b7cbf76d0036a314234e4e58c24fa794b3cb8149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alois=20Se=C4=8Dk=C3=A1r?= Date: Sat, 28 Jun 2025 21:15:25 +0200 Subject: [PATCH] feat: more enhanced code blocks (follow up for #3235) --- src/api/sfc-script-setup.md | 16 ++++--- src/guide/built-ins/transition.md | 3 +- src/guide/components/provide-inject.md | 5 +-- src/guide/components/v-model.md | 55 ++++++++++-------------- src/guide/essentials/component-basics.md | 23 ++++------ src/guide/extras/web-components.md | 22 +++------- src/guide/reusability/composables.md | 19 +++----- src/guide/reusability/plugins.md | 9 ++-- src/guide/scaling-up/ssr.md | 8 ++-- src/guide/scaling-up/state-management.md | 18 +++----- src/guide/scaling-up/testing.md | 4 +- src/guide/typescript/composition-api.md | 9 ++-- src/style-guide/rules-recommended.md | 22 +++++----- src/tutorial/src/step-12/description.md | 3 +- 14 files changed, 91 insertions(+), 125 deletions(-) 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] +