@nuxt/docs 4.1.1 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/1.getting-started/01.introduction.md +6 -6
- package/1.getting-started/02.installation.md +2 -1
- package/1.getting-started/03.configuration.md +37 -37
- package/1.getting-started/04.views.md +9 -9
- package/1.getting-started/05.assets.md +15 -9
- package/1.getting-started/06.styling.md +58 -48
- package/1.getting-started/07.routing.md +17 -17
- package/1.getting-started/08.seo-meta.md +59 -46
- package/1.getting-started/09.transitions.md +49 -44
- package/1.getting-started/10.data-fetching.md +104 -81
- package/1.getting-started/11.state-management.md +27 -20
- package/1.getting-started/12.error-handling.md +22 -20
- package/1.getting-started/13.server.md +8 -8
- package/1.getting-started/14.layers.md +22 -16
- package/1.getting-started/15.prerendering.md +32 -32
- package/1.getting-started/16.deployment.md +10 -10
- package/1.getting-started/17.testing.md +44 -44
- package/1.getting-started/18.upgrade.md +53 -71
- package/2.guide/0.index.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/.navigation.yml +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/0.nuxt.md +3 -3
- package/2.guide/1.directory-structure/0.output.md +18 -0
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/.navigation.yml +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.assets.md +4 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.components.md +49 -28
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.composables.md +13 -13
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.layouts.md +19 -15
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.middleware.md +31 -25
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.pages.md +39 -37
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.plugins.md +25 -25
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.utils.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app-config.md +18 -18
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.error.md +6 -6
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.content.md +7 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.modules.md +8 -8
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.node_modules.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.public.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.server.md +35 -35
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.shared.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.env.md +8 -8
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.gitignore.md +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtignore.md +5 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtrc.md +4 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.nuxt-config.md +3 -3
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.package.md +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.tsconfig.md +3 -3
- package/2.guide/{1.concepts → 2.concepts}/1.auto-imports.md +22 -22
- package/2.guide/{1.concepts → 2.concepts}/10.nuxt-lifecycle.md +17 -17
- package/2.guide/{1.concepts → 2.concepts}/2.vuejs-development.md +13 -13
- package/2.guide/{1.concepts → 2.concepts}/3.rendering.md +24 -22
- package/2.guide/{1.concepts → 2.concepts}/4.server-engine.md +6 -6
- package/2.guide/{1.concepts → 2.concepts}/5.modules.md +5 -5
- package/2.guide/{1.concepts → 2.concepts}/7.esm.md +17 -15
- package/2.guide/{1.concepts → 2.concepts}/8.typescript.md +12 -12
- package/2.guide/3.going-further/1.events.md +3 -3
- package/2.guide/3.going-further/1.experimental-features.md +246 -85
- package/2.guide/3.going-further/1.features.md +44 -9
- package/2.guide/3.going-further/1.internals.md +25 -25
- package/2.guide/3.going-further/10.runtime-config.md +12 -12
- package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
- package/2.guide/3.going-further/2.hooks.md +14 -14
- package/2.guide/3.going-further/3.modules.md +96 -94
- package/2.guide/3.going-further/4.kit.md +7 -7
- package/2.guide/3.going-further/6.nuxt-app.md +8 -8
- package/2.guide/3.going-further/7.layers.md +62 -53
- package/2.guide/3.going-further/9.debugging.md +2 -2
- package/2.guide/4.recipes/1.custom-routing.md +30 -30
- package/2.guide/4.recipes/2.vite-plugin.md +4 -4
- package/2.guide/4.recipes/3.custom-usefetch.md +13 -13
- package/2.guide/4.recipes/4.sessions-and-authentication.md +35 -21
- package/2.guide/5.best-practices/hydration.md +4 -4
- package/2.guide/5.best-practices/performance.md +17 -17
- package/3.api/1.components/1.client-only.md +6 -3
- package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
- package/3.api/1.components/10.nuxt-picture.md +1 -1
- package/3.api/1.components/11.teleports.md +5 -2
- package/3.api/1.components/12.nuxt-route-announcer.md +9 -9
- package/3.api/1.components/13.nuxt-time.md +44 -17
- package/3.api/1.components/2.nuxt-page.md +6 -6
- package/3.api/1.components/3.nuxt-layout.md +15 -10
- package/3.api/1.components/4.nuxt-link.md +42 -22
- package/3.api/1.components/5.nuxt-loading-indicator.md +3 -3
- package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
- package/3.api/2.composables/on-prehydrate.md +2 -2
- package/3.api/2.composables/use-app-config.md +1 -1
- package/3.api/2.composables/use-async-data.md +20 -20
- package/3.api/2.composables/use-cookie.md +29 -21
- package/3.api/2.composables/use-error.md +2 -2
- package/3.api/2.composables/use-fetch.md +58 -32
- package/3.api/2.composables/use-head-safe.md +7 -7
- package/3.api/2.composables/use-head.md +5 -5
- package/3.api/2.composables/use-hydration.md +6 -6
- package/3.api/2.composables/use-lazy-async-data.md +4 -4
- package/3.api/2.composables/use-lazy-fetch.md +4 -4
- package/3.api/2.composables/use-loading-indicator.md +12 -12
- package/3.api/2.composables/use-nuxt-app.md +22 -22
- package/3.api/2.composables/use-nuxt-data.md +8 -8
- package/3.api/2.composables/use-preview-mode.md +15 -18
- package/3.api/2.composables/use-request-event.md +1 -1
- package/3.api/2.composables/use-request-fetch.md +3 -3
- package/3.api/2.composables/use-request-header.md +1 -1
- package/3.api/2.composables/use-request-headers.md +4 -4
- package/3.api/2.composables/use-request-url.md +1 -1
- package/3.api/2.composables/use-response-header.md +9 -10
- package/3.api/2.composables/use-route-announcer.md +4 -4
- package/3.api/2.composables/use-route.md +1 -1
- package/3.api/2.composables/use-router.md +10 -8
- package/3.api/2.composables/use-runtime-config.md +11 -11
- package/3.api/2.composables/use-runtime-hook.md +2 -2
- package/3.api/2.composables/use-seo-meta.md +4 -4
- package/3.api/2.composables/use-server-seo-meta.md +6 -6
- package/3.api/2.composables/use-state.md +5 -5
- package/3.api/3.utils/$fetch.md +10 -8
- package/3.api/3.utils/abort-navigation.md +3 -3
- package/3.api/3.utils/add-route-middleware.md +5 -5
- package/3.api/3.utils/call-once.md +6 -6
- package/3.api/3.utils/clear-error.md +3 -3
- package/3.api/3.utils/clear-nuxt-data.md +3 -3
- package/3.api/3.utils/clear-nuxt-state.md +3 -3
- package/3.api/3.utils/create-error.md +2 -2
- package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
- package/3.api/3.utils/define-nuxt-component.md +5 -5
- package/3.api/3.utils/define-nuxt-plugin.md +13 -13
- package/3.api/3.utils/define-nuxt-route-middleware.md +5 -5
- package/3.api/3.utils/define-page-meta.md +23 -23
- package/3.api/3.utils/define-route-rules.md +7 -7
- package/3.api/3.utils/navigate-to.md +11 -11
- package/3.api/3.utils/prefetch-components.md +1 -1
- package/3.api/3.utils/preload-components.md +1 -1
- package/3.api/3.utils/preload-route-components.md +2 -2
- package/3.api/3.utils/prerender-routes.md +3 -3
- package/3.api/3.utils/refresh-cookie.md +4 -4
- package/3.api/3.utils/refresh-nuxt-data.md +12 -7
- package/3.api/3.utils/reload-nuxt-app.md +3 -3
- package/3.api/3.utils/set-page-layout.md +1 -1
- package/3.api/3.utils/set-response-status.md +3 -3
- package/3.api/3.utils/show-error.md +5 -5
- package/3.api/3.utils/update-app-config.md +4 -3
- package/3.api/4.commands/add.md +1 -1
- package/3.api/4.commands/analyze.md +2 -1
- package/3.api/4.commands/build.md +2 -1
- package/3.api/4.commands/dev.md +5 -4
- package/3.api/4.commands/generate.md +3 -2
- package/3.api/4.commands/init.md +3 -2
- package/3.api/4.commands/module.md +4 -4
- package/3.api/4.commands/prepare.md +7 -2
- package/3.api/4.commands/preview.md +5 -4
- package/3.api/4.commands/test.md +40 -0
- package/3.api/4.commands/typecheck.md +5 -3
- package/3.api/4.commands/upgrade.md +3 -3
- package/3.api/5.kit/1.modules.md +36 -36
- package/3.api/5.kit/10.runtime-config.md +1 -1
- package/3.api/5.kit/10.templates.md +8 -6
- package/3.api/5.kit/11.nitro.md +62 -62
- package/3.api/5.kit/12.resolving.md +2 -2
- package/3.api/5.kit/14.builder.md +1 -0
- package/3.api/5.kit/15.examples.md +2 -2
- package/3.api/5.kit/16.layers.md +26 -26
- package/3.api/5.kit/3.compatibility.md +14 -14
- package/3.api/5.kit/4.autoimports.md +13 -13
- package/3.api/5.kit/5.components.md +7 -8
- package/3.api/5.kit/6.context.md +3 -3
- package/3.api/5.kit/7.pages.md +7 -7
- package/3.api/5.kit/8.layout.md +2 -2
- package/3.api/5.kit/9.plugins.md +5 -4
- package/3.api/6.advanced/1.hooks.md +3 -3
- package/3.api/6.advanced/2.import-meta.md +3 -3
- package/3.api/6.nuxt-config.md +300 -865
- package/3.api/index.md +7 -7
- package/5.community/2.getting-help.md +1 -1
- package/5.community/3.reporting-bugs.md +1 -1
- package/5.community/4.contribution.md +11 -11
- package/5.community/5.framework-contribution.md +4 -4
- package/5.community/6.roadmap.md +1 -1
- package/6.bridge/1.overview.md +13 -13
- package/6.bridge/10.configuration.md +2 -1
- package/6.bridge/2.typescript.md +3 -3
- package/6.bridge/3.bridge-composition-api.md +8 -8
- package/6.bridge/4.plugins-and-middleware.md +9 -9
- package/6.bridge/5.nuxt3-compatible-api.md +20 -17
- package/6.bridge/6.meta.md +21 -20
- package/6.bridge/7.runtime-config.md +1 -1
- package/6.bridge/8.nitro.md +3 -3
- package/6.bridge/9.vite.md +4 -4
- package/7.migration/1.overview.md +2 -2
- package/7.migration/10.bundling.md +1 -1
- package/7.migration/11.server.md +3 -3
- package/7.migration/2.configuration.md +23 -21
- package/7.migration/20.module-authors.md +7 -7
- package/7.migration/3.auto-imports.md +3 -3
- package/7.migration/4.meta.md +21 -18
- package/7.migration/5.plugins-and-middleware.md +8 -8
- package/7.migration/6.pages-and-layouts.md +28 -24
- package/7.migration/7.component-options.md +18 -18
- package/7.migration/8.runtime-config.md +7 -7
- package/package.json +1 -1
- package/2.guide/2.directory-structure/0.output.md +0 -18
- /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
- /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
|
@@ -12,14 +12,14 @@ We made everything so you can start writing `.vue` files from the beginning whil
|
|
|
12
12
|
Nuxt has no vendor lock-in, allowing you to deploy your application [**everywhere, even on the edge**](/blog/nuxt-on-the-edge).
|
|
13
13
|
|
|
14
14
|
::tip
|
|
15
|
-
If you want to play around with Nuxt in your browser, you can [try it out in one of our online sandboxes](/docs/getting-started/installation#play-online).
|
|
15
|
+
If you want to play around with Nuxt in your browser, you can [try it out in one of our online sandboxes](/docs/4.x/getting-started/installation#play-online).
|
|
16
16
|
::
|
|
17
17
|
|
|
18
18
|
## Automation and Conventions
|
|
19
19
|
|
|
20
20
|
Nuxt uses conventions and an opinionated directory structure to automate repetitive tasks and allow developers to focus on pushing features. The configuration file can still customize and override its default behaviors.
|
|
21
21
|
|
|
22
|
-
- **File-based routing:** define routes based on the structure of your [`app/pages/` directory](/docs/guide/directory-structure/app/pages). This can make it easier to organize your application and avoid the need for manual route configuration.
|
|
22
|
+
- **File-based routing:** define routes based on the structure of your [`app/pages/` directory](/docs/4.x/guide/directory-structure/app/pages). This can make it easier to organize your application and avoid the need for manual route configuration.
|
|
23
23
|
- **Code splitting:** Nuxt automatically splits your code into smaller chunks, which can help reduce the initial load time of your application.
|
|
24
24
|
- **Server-side rendering out of the box:** Nuxt comes with built-in SSR capabilities, so you don't have to set up a separate server yourself.
|
|
25
25
|
- **Auto-imports:** write Vue composables and components in their respective directories and use them without having to import them with the benefits of tree-shaking and optimized JS bundles.
|
|
@@ -44,7 +44,7 @@ Overall, server-side rendering can provide a faster and more efficient user expe
|
|
|
44
44
|
As Nuxt is a versatile framework, it gives you the possibility to statically render your whole application to a static hosting with `nuxt generate`,
|
|
45
45
|
disable SSR globally with the `ssr: false` option or leverage hybrid rendering by setting up the `routeRules` option.
|
|
46
46
|
|
|
47
|
-
:read-more{title="Nuxt rendering modes" to="/docs/guide/concepts/rendering"}
|
|
47
|
+
:read-more{title="Nuxt rendering modes" to="/docs/4.x/guide/concepts/rendering"}
|
|
48
48
|
|
|
49
49
|
### Server engine
|
|
50
50
|
|
|
@@ -54,19 +54,19 @@ In development, it uses Rollup and Node.js workers for your server code and cont
|
|
|
54
54
|
|
|
55
55
|
In production, Nitro builds your app and server into one universal `.output` directory. This output is light: minified and removed from any Node.js modules (except polyfills). You can deploy this output on any system supporting JavaScript, from Node.js, Serverless, Workers, Edge-side rendering or purely static.
|
|
56
56
|
|
|
57
|
-
:read-more{title="Nuxt server engine" to="/docs/guide/concepts/server-engine"}
|
|
57
|
+
:read-more{title="Nuxt server engine" to="/docs/4.x/guide/concepts/server-engine"}
|
|
58
58
|
|
|
59
59
|
### Production-ready
|
|
60
60
|
|
|
61
61
|
A Nuxt application can be deployed on a Node or Deno server, pre-rendered to be hosted in static environments, or deployed to serverless and edge providers.
|
|
62
62
|
|
|
63
|
-
:read-more{title="Deployment section" to="/docs/getting-started/deployment"}
|
|
63
|
+
:read-more{title="Deployment section" to="/docs/4.x/getting-started/deployment"}
|
|
64
64
|
|
|
65
65
|
### Modular
|
|
66
66
|
|
|
67
67
|
A module system allows you to extend Nuxt with custom features and integrations with third-party services.
|
|
68
68
|
|
|
69
|
-
:read-more{title="Nuxt Modules Concept" to="/docs/guide/concepts/modules"}
|
|
69
|
+
:read-more{title="Nuxt Modules Concept" to="/docs/4.x/guide/concepts/modules"}
|
|
70
70
|
|
|
71
71
|
### Architecture
|
|
72
72
|
|
|
@@ -31,6 +31,7 @@ Or follow the steps below to set up a new Nuxt project on your computer.
|
|
|
31
31
|
- **Node.js**: Make sure to use an even numbered version (18, 20, etc)
|
|
32
32
|
- **Nuxtr**: Install the community-developed [Nuxtr extension](https://marketplace.visualstudio.com/items?itemName=Nuxtr.nuxtr-vscode)
|
|
33
33
|
- **WSL**: If you are using Windows and experience slow HMR, you may want to try using [WSL (Windows Subsystem for Linux)](https://docs.microsoft.com/en-us/windows/wsl/install) which may solve some performance issues.
|
|
34
|
+
- **Windows slow DNS resolution** - instead of using `localhost:3000` for local dev server on Windows, use `127.0.0.1` for much faster loading experience on browsers.
|
|
34
35
|
::
|
|
35
36
|
::
|
|
36
37
|
|
|
@@ -114,4 +115,4 @@ Well done! A browser window should automatically open for <http://localhost:3000
|
|
|
114
115
|
|
|
115
116
|
Now that you've created your Nuxt project, you are ready to start building your application.
|
|
116
117
|
|
|
117
|
-
:read-more{title="Nuxt Concepts" to="/docs/guide/concepts"}
|
|
118
|
+
:read-more{title="Nuxt Concepts" to="/docs/4.x/guide/concepts"}
|
|
@@ -4,11 +4,11 @@ description: Nuxt is configured with sensible defaults to make you productive.
|
|
|
4
4
|
navigation.icon: i-lucide-cog
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
By default, Nuxt is configured to cover most use cases. The [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) file can override or extend this default configuration.
|
|
7
|
+
By default, Nuxt is configured to cover most use cases. The [`nuxt.config.ts`](/docs/4.x/guide/directory-structure/nuxt-config) file can override or extend this default configuration.
|
|
8
8
|
|
|
9
9
|
## Nuxt Configuration
|
|
10
10
|
|
|
11
|
-
The [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) file is located at the root of a Nuxt project and can override or extend the application's behavior.
|
|
11
|
+
The [`nuxt.config.ts`](/docs/4.x/guide/directory-structure/nuxt-config) file is located at the root of a Nuxt project and can override or extend the application's behavior.
|
|
12
12
|
|
|
13
13
|
A minimal configuration file exports the `defineNuxtConfig` function containing an object with your configuration. The `defineNuxtConfig` helper is globally available without import.
|
|
14
14
|
|
|
@@ -20,7 +20,7 @@ export default defineNuxtConfig({
|
|
|
20
20
|
|
|
21
21
|
This file will often be mentioned in the documentation, for example to add custom scripts, register modules or change rendering modes.
|
|
22
22
|
|
|
23
|
-
::read-more{to="/docs/api/configuration/nuxt-config"}
|
|
23
|
+
::read-more{to="/docs/4.x/api/configuration/nuxt-config"}
|
|
24
24
|
Every option is described in the **Configuration Reference**.
|
|
25
25
|
::
|
|
26
26
|
|
|
@@ -36,16 +36,16 @@ You can configure fully typed, per-environment overrides in your nuxt.config
|
|
|
36
36
|
export default defineNuxtConfig({
|
|
37
37
|
$production: {
|
|
38
38
|
routeRules: {
|
|
39
|
-
'/**': { isr: true }
|
|
40
|
-
}
|
|
39
|
+
'/**': { isr: true },
|
|
40
|
+
},
|
|
41
41
|
},
|
|
42
42
|
$development: {
|
|
43
43
|
//
|
|
44
44
|
},
|
|
45
45
|
$env: {
|
|
46
46
|
staging: {
|
|
47
|
-
//
|
|
48
|
-
}
|
|
47
|
+
//
|
|
48
|
+
},
|
|
49
49
|
},
|
|
50
50
|
})
|
|
51
51
|
```
|
|
@@ -75,9 +75,9 @@ export default defineNuxtConfig({
|
|
|
75
75
|
apiSecret: '123',
|
|
76
76
|
// Keys within public are also exposed client-side
|
|
77
77
|
public: {
|
|
78
|
-
apiBase: '/api'
|
|
79
|
-
}
|
|
80
|
-
}
|
|
78
|
+
apiBase: '/api',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
81
|
})
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -88,7 +88,7 @@ NUXT_API_SECRET=api_secret_token
|
|
|
88
88
|
|
|
89
89
|
::
|
|
90
90
|
|
|
91
|
-
These variables are exposed to the rest of your application using the [`useRuntimeConfig()`](/docs/api/composables/use-runtime-config) composable.
|
|
91
|
+
These variables are exposed to the rest of your application using the [`useRuntimeConfig()`](/docs/4.x/api/composables/use-runtime-config) composable.
|
|
92
92
|
|
|
93
93
|
```vue [app/pages/index.vue]
|
|
94
94
|
<script setup lang="ts">
|
|
@@ -96,27 +96,27 @@ const runtimeConfig = useRuntimeConfig()
|
|
|
96
96
|
</script>
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
:read-more{to="/docs/guide/going-further/runtime-config"}
|
|
99
|
+
:read-more{to="/docs/4.x/guide/going-further/runtime-config"}
|
|
100
100
|
|
|
101
101
|
## App Configuration
|
|
102
102
|
|
|
103
|
-
The `app.config.ts` file, located in the source directory (by default
|
|
103
|
+
The `app.config.ts` file, located in the source directory (by default `app/`), is used to expose public variables that can be determined at build time. Contrary to the `runtimeConfig` option, these cannot be overridden using environment variables.
|
|
104
104
|
|
|
105
105
|
A minimal configuration file exports the `defineAppConfig` function containing an object with your configuration. The `defineAppConfig` helper is globally available without import.
|
|
106
106
|
|
|
107
|
-
```ts [app.config.ts]
|
|
107
|
+
```ts [app/app.config.ts]
|
|
108
108
|
export default defineAppConfig({
|
|
109
109
|
title: 'Hello Nuxt',
|
|
110
110
|
theme: {
|
|
111
111
|
dark: true,
|
|
112
112
|
colors: {
|
|
113
|
-
primary: '#ff0000'
|
|
114
|
-
}
|
|
115
|
-
}
|
|
113
|
+
primary: '#ff0000',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
116
|
})
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
These variables are exposed to the rest of your application using the [`useAppConfig`](/docs/api/composables/use-app-config) composable.
|
|
119
|
+
These variables are exposed to the rest of your application using the [`useAppConfig`](/docs/4.x/api/composables/use-app-config) composable.
|
|
120
120
|
|
|
121
121
|
```vue [app/pages/index.vue]
|
|
122
122
|
<script setup lang="ts">
|
|
@@ -124,7 +124,7 @@ const appConfig = useAppConfig()
|
|
|
124
124
|
</script>
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
:read-more{to="/docs/guide/directory-structure/app-config"}
|
|
127
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app-config"}
|
|
128
128
|
|
|
129
129
|
## `runtimeConfig` vs. `app.config`
|
|
130
130
|
|
|
@@ -145,20 +145,20 @@ Non primitive JS types | ❌ No | ✅ Yes
|
|
|
145
145
|
|
|
146
146
|
## External Configuration Files
|
|
147
147
|
|
|
148
|
-
Nuxt uses [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) file as the single source of truth for configurations and skips reading external configuration files. During the course of building your project, you may have a need to configure those. The following table highlights common configurations and, where applicable, how they can be configured with Nuxt.
|
|
148
|
+
Nuxt uses [`nuxt.config.ts`](/docs/4.x/guide/directory-structure/nuxt-config) file as the single source of truth for configurations and skips reading external configuration files. During the course of building your project, you may have a need to configure those. The following table highlights common configurations and, where applicable, how they can be configured with Nuxt.
|
|
149
149
|
|
|
150
150
|
Name | Config File | How To Configure
|
|
151
151
|
---------------------------------------------|---------------------------|-------------------------
|
|
152
|
-
[Nitro](https://nitro.build) | ~~`nitro.config.ts`~~ | Use [`nitro`](/docs/api/nuxt-config#nitro) key in `nuxt.config`
|
|
153
|
-
[PostCSS](https://postcss.org) | ~~`postcss.config.js`~~ | Use [`postcss`](/docs/api/nuxt-config#postcss) key in `nuxt.config`
|
|
154
|
-
[Vite](https://vite.dev) | ~~`vite.config.ts`~~ | Use [`vite`](/docs/api/nuxt-config#vite) key in `nuxt.config`
|
|
155
|
-
[webpack](https://webpack.js.org) | ~~`webpack.config.ts`~~ | Use [`webpack`](/docs/api/nuxt-config#webpack-1) key in `nuxt.config`
|
|
152
|
+
[Nitro](https://nitro.build) | ~~`nitro.config.ts`~~ | Use [`nitro`](/docs/4.x/api/nuxt-config#nitro) key in `nuxt.config`
|
|
153
|
+
[PostCSS](https://postcss.org) | ~~`postcss.config.js`~~ | Use [`postcss`](/docs/4.x/api/nuxt-config#postcss) key in `nuxt.config`
|
|
154
|
+
[Vite](https://vite.dev) | ~~`vite.config.ts`~~ | Use [`vite`](/docs/4.x/api/nuxt-config#vite) key in `nuxt.config`
|
|
155
|
+
[webpack](https://webpack.js.org) | ~~`webpack.config.ts`~~ | Use [`webpack`](/docs/4.x/api/nuxt-config#webpack-1) key in `nuxt.config`
|
|
156
156
|
|
|
157
157
|
Here is a list of other common config files:
|
|
158
158
|
|
|
159
159
|
Name | Config File | How To Configure
|
|
160
160
|
---------------------------------------------|-------------------------|--------------------------
|
|
161
|
-
[TypeScript](https://www.typescriptlang.org) | `tsconfig.json` | [More Info](/docs/guide/
|
|
161
|
+
[TypeScript](https://www.typescriptlang.org) | `tsconfig.json` | [More Info](/docs/4.x/guide/directory-structure/tsconfig)
|
|
162
162
|
[ESLint](https://eslint.org) | `eslint.config.js` | [More Info](https://eslint.org/docs/latest/use/configure/configuration-files)
|
|
163
163
|
[Prettier](https://prettier.io) | `prettier.config.js` | [More Info](https://prettier.io/docs/en/configuration.html)
|
|
164
164
|
[Stylelint](https://stylelint.io) | `stylelint.config.js` | [More Info](https://stylelint.io/user-guide/configure)
|
|
@@ -178,16 +178,16 @@ If you need to pass options to `@vitejs/plugin-vue` or `@vitejs/plugin-vue-jsx`,
|
|
|
178
178
|
export default defineNuxtConfig({
|
|
179
179
|
vite: {
|
|
180
180
|
vue: {
|
|
181
|
-
customElement: true
|
|
181
|
+
customElement: true,
|
|
182
182
|
},
|
|
183
183
|
vueJsx: {
|
|
184
|
-
mergeProps: true
|
|
185
|
-
}
|
|
186
|
-
}
|
|
184
|
+
mergeProps: true,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
187
|
})
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
:read-more{to="/docs/api/configuration/nuxt-config#vue"}
|
|
190
|
+
:read-more{to="/docs/4.x/api/configuration/nuxt-config#vue"}
|
|
191
191
|
|
|
192
192
|
### With webpack
|
|
193
193
|
|
|
@@ -199,13 +199,13 @@ export default defineNuxtConfig({
|
|
|
199
199
|
loaders: {
|
|
200
200
|
vue: {
|
|
201
201
|
hotReload: true,
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
205
|
})
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
:read-more{to="/docs/api/configuration/nuxt-config#loaders"}
|
|
208
|
+
:read-more{to="/docs/4.x/api/configuration/nuxt-config#loaders"}
|
|
209
209
|
|
|
210
210
|
### Enabling Experimental Vue Features
|
|
211
211
|
|
|
@@ -214,8 +214,8 @@ You may need to enable experimental features in Vue, such as `propsDestructure`.
|
|
|
214
214
|
```ts twoslash [nuxt.config.ts]
|
|
215
215
|
export default defineNuxtConfig({
|
|
216
216
|
vue: {
|
|
217
|
-
propsDestructure: true
|
|
218
|
-
}
|
|
217
|
+
propsDestructure: true,
|
|
218
|
+
},
|
|
219
219
|
})
|
|
220
220
|
```
|
|
221
221
|
|
|
@@ -223,4 +223,4 @@ export default defineNuxtConfig({
|
|
|
223
223
|
|
|
224
224
|
Since Nuxt 3.9 and Vue 3.4, `reactivityTransform` has been moved from Vue to Vue Macros which has a [Nuxt integration](https://vue-macros.dev/guide/nuxt-integration.html).
|
|
225
225
|
|
|
226
|
-
:read-more{to="/docs/api/configuration/nuxt-config#vue-1"}
|
|
226
|
+
:read-more{to="/docs/4.x/api/configuration/nuxt-config#vue-1"}
|
|
@@ -13,7 +13,7 @@ By default, Nuxt will treat this file as the **entrypoint** and render its conte
|
|
|
13
13
|
```vue [app/app.vue]
|
|
14
14
|
<template>
|
|
15
15
|
<div>
|
|
16
|
-
|
|
16
|
+
<h1>Welcome to the homepage</h1>
|
|
17
17
|
</div>
|
|
18
18
|
</template>
|
|
19
19
|
```
|
|
@@ -26,7 +26,7 @@ If you are familiar with Vue, you might wonder where `main.js` is (the file that
|
|
|
26
26
|
|
|
27
27
|

|
|
28
28
|
|
|
29
|
-
Most components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the [`app/components/`](/docs/guide/directory-structure/app/components) directory, and they will be automatically available across your application without having to explicitly import them.
|
|
29
|
+
Most components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the [`app/components/`](/docs/4.x/guide/directory-structure/app/components) directory, and they will be automatically available across your application without having to explicitly import them.
|
|
30
30
|
|
|
31
31
|
::code-group
|
|
32
32
|
|
|
@@ -55,9 +55,9 @@ Most components are reusable pieces of the user interface, like buttons and menu
|
|
|
55
55
|
|
|
56
56
|

|
|
57
57
|
|
|
58
|
-
Pages represent views for each specific route pattern. Every file in the [`app/pages/`](/docs/guide/directory-structure/app/pages) directory represents a different route displaying its content.
|
|
58
|
+
Pages represent views for each specific route pattern. Every file in the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory represents a different route displaying its content.
|
|
59
59
|
|
|
60
|
-
To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` component to the [`app/app.vue`](/docs/guide/directory-structure/app) (or remove `app/app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the [`app/pages/`](/docs/guide/directory-structure/app/pages) directory.
|
|
60
|
+
To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` component to the [`app/app.vue`](/docs/4.x/guide/directory-structure/app) (or remove `app/app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory.
|
|
61
61
|
|
|
62
62
|
::code-group
|
|
63
63
|
|
|
@@ -82,7 +82,7 @@ To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` compon
|
|
|
82
82
|
|
|
83
83
|
::
|
|
84
84
|
|
|
85
|
-
:read-more{title="Routing Section" to="/docs/getting-started/routing"}
|
|
85
|
+
:read-more{title="Routing Section" to="/docs/4.x/getting-started/routing"}
|
|
86
86
|
|
|
87
87
|
## Layouts
|
|
88
88
|
|
|
@@ -91,7 +91,7 @@ To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` compon
|
|
|
91
91
|
Layouts are wrappers around pages that contain a common User Interface for several pages, such as header and footer displays. Layouts are Vue files using `<slot />` components to display the **page** content. The `app/layouts/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata.
|
|
92
92
|
|
|
93
93
|
::note
|
|
94
|
-
If you only have a single layout in your application, we recommend using [`app/app.vue`](/docs/guide/directory-structure/app) with [`<NuxtPage />`](/docs/api/components/nuxt-page) instead.
|
|
94
|
+
If you only have a single layout in your application, we recommend using [`app/app.vue`](/docs/4.x/guide/directory-structure/app) with [`<NuxtPage />`](/docs/4.x/api/components/nuxt-page) instead.
|
|
95
95
|
::
|
|
96
96
|
|
|
97
97
|
::code-group
|
|
@@ -137,12 +137,12 @@ If you only have a single layout in your application, we recommend using [`app/a
|
|
|
137
137
|
|
|
138
138
|
::
|
|
139
139
|
|
|
140
|
-
If you want to create more layouts and learn how to use them in your pages, find more information in the [Layouts section](/docs/guide/directory-structure/app/layouts).
|
|
140
|
+
If you want to create more layouts and learn how to use them in your pages, find more information in the [Layouts section](/docs/4.x/guide/directory-structure/app/layouts).
|
|
141
141
|
|
|
142
142
|
## Advanced: Extending the HTML Template
|
|
143
143
|
|
|
144
144
|
::note
|
|
145
|
-
If you only need to modify the `<head>`, you can refer to the [SEO and meta section](/docs/getting-started/seo-meta).
|
|
145
|
+
If you only need to modify the `<head>`, you can refer to the [SEO and meta section](/docs/4.x/getting-started/seo-meta).
|
|
146
146
|
::
|
|
147
147
|
|
|
148
148
|
You can have full control over the HTML template by adding a Nitro plugin that registers a hook.
|
|
@@ -162,4 +162,4 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
162
162
|
})
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
:read-more{to="/docs/guide/going-further/hooks"}
|
|
165
|
+
:read-more{to="/docs/4.x/guide/going-further/hooks"}
|
|
@@ -6,14 +6,14 @@ navigation.icon: i-lucide-image
|
|
|
6
6
|
|
|
7
7
|
Nuxt uses two directories to handle assets like stylesheets, fonts or images.
|
|
8
8
|
|
|
9
|
-
- The [`public/`](/docs/guide/directory-structure/public) directory content is served at the server root as-is.
|
|
10
|
-
- The [`app/assets/`](/docs/guide/directory-structure/app/assets) directory contains by convention every asset that you want the build tool (Vite or webpack) to process.
|
|
9
|
+
- The [`public/`](/docs/4.x/guide/directory-structure/public) directory content is served at the server root as-is.
|
|
10
|
+
- The [`app/assets/`](/docs/4.x/guide/directory-structure/app/assets) directory contains by convention every asset that you want the build tool (Vite or webpack) to process.
|
|
11
11
|
|
|
12
12
|
## Public Directory
|
|
13
13
|
|
|
14
|
-
The [`public/`](/docs/guide/directory-structure/public) directory is used as a public server for static assets publicly available at a defined URL of your application.
|
|
14
|
+
The [`public/`](/docs/4.x/guide/directory-structure/public) directory is used as a public server for static assets publicly available at a defined URL of your application.
|
|
15
15
|
|
|
16
|
-
You can get a file in the [`public/`](/docs/guide/directory-structure/public) directory from your application's code or from a browser by the root URL `/`.
|
|
16
|
+
You can get a file in the [`public/`](/docs/4.x/guide/directory-structure/public) directory from your application's code or from a browser by the root URL `/`.
|
|
17
17
|
|
|
18
18
|
### Example
|
|
19
19
|
|
|
@@ -21,7 +21,10 @@ For example, referencing an image file in the `public/img/` directory, available
|
|
|
21
21
|
|
|
22
22
|
```vue [app/app.vue]
|
|
23
23
|
<template>
|
|
24
|
-
<img
|
|
24
|
+
<img
|
|
25
|
+
src="/img/nuxt.png"
|
|
26
|
+
alt="Discover Nuxt"
|
|
27
|
+
>
|
|
25
28
|
</template>
|
|
26
29
|
```
|
|
27
30
|
|
|
@@ -29,9 +32,9 @@ For example, referencing an image file in the `public/img/` directory, available
|
|
|
29
32
|
|
|
30
33
|
Nuxt uses [Vite](https://vite.dev/guide/assets.html) (default) or [webpack](https://webpack.js.org/guides/asset-management) to build and bundle your application. The main function of these build tools is to process JavaScript files, but they can be extended through [plugins](https://vite.dev/plugins) (for Vite) or [loaders](https://webpack.js.org/loaders) (for webpack) to process other kinds of assets, like stylesheets, fonts or SVGs. This step transforms the original file, mainly for performance or caching purposes (such as stylesheet minification or browser cache invalidation).
|
|
31
34
|
|
|
32
|
-
By convention, Nuxt uses the [`app/assets/`](/docs/guide/directory-structure/app/assets) directory to store these files but there is no auto-scan functionality for this directory, and you can use any other name for it.
|
|
35
|
+
By convention, Nuxt uses the [`app/assets/`](/docs/4.x/guide/directory-structure/app/assets) directory to store these files but there is no auto-scan functionality for this directory, and you can use any other name for it.
|
|
33
36
|
|
|
34
|
-
In your application's code, you can reference a file located in the [`app/assets/`](/docs/guide/directory-structure/app/assets) directory by using the `~/assets/` path.
|
|
37
|
+
In your application's code, you can reference a file located in the [`app/assets/`](/docs/4.x/guide/directory-structure/app/assets) directory by using the `~/assets/` path.
|
|
35
38
|
|
|
36
39
|
### Example
|
|
37
40
|
|
|
@@ -39,10 +42,13 @@ For example, referencing an image file that will be processed if a build tool is
|
|
|
39
42
|
|
|
40
43
|
```vue [app/app.vue]
|
|
41
44
|
<template>
|
|
42
|
-
<img
|
|
45
|
+
<img
|
|
46
|
+
src="~/assets/img/nuxt.png"
|
|
47
|
+
alt="Discover Nuxt"
|
|
48
|
+
>
|
|
43
49
|
</template>
|
|
44
50
|
```
|
|
45
51
|
|
|
46
52
|
::note
|
|
47
|
-
Nuxt won't serve files in the [`app/assets/`](/docs/guide/directory-structure/app/assets) directory at a static URL like `/assets/my-file.png`. If you need a static URL, use the [`public/`](#public-directory) directory.
|
|
53
|
+
Nuxt won't serve files in the [`app/assets/`](/docs/4.x/guide/directory-structure/app/assets) directory at a static URL like `/assets/my-file.png`. If you need a static URL, use the [`public/`](/docs/4.x/getting-started/assets#public-directory) directory.
|
|
48
54
|
::
|
|
@@ -9,7 +9,7 @@ You can use CSS preprocessors, CSS frameworks, UI libraries and Nuxt modules to
|
|
|
9
9
|
|
|
10
10
|
## Local Stylesheets
|
|
11
11
|
|
|
12
|
-
If you're writing local stylesheets, the natural place to put them is the [`app/assets/` directory](/docs/guide/directory-structure/app/assets).
|
|
12
|
+
If you're writing local stylesheets, the natural place to put them is the [`app/assets/` directory](/docs/4.x/guide/directory-structure/app/assets).
|
|
13
13
|
|
|
14
14
|
### Importing Within Components
|
|
15
15
|
|
|
@@ -37,11 +37,11 @@ The stylesheets will be inlined in the HTML rendered by Nuxt.
|
|
|
37
37
|
### The CSS Property
|
|
38
38
|
|
|
39
39
|
You can also use the `css` property in the Nuxt configuration.
|
|
40
|
-
The natural place for your stylesheets is the [`app/assets/` directory](/docs/guide/directory-structure/app/assets). You can then reference its path and Nuxt will include it to all the pages of your application.
|
|
40
|
+
The natural place for your stylesheets is the [`app/assets/` directory](/docs/4.x/guide/directory-structure/app/assets). You can then reference its path and Nuxt will include it to all the pages of your application.
|
|
41
41
|
|
|
42
42
|
```ts [nuxt.config.ts]
|
|
43
43
|
export default defineNuxtConfig({
|
|
44
|
-
css: ['~/assets/css/main.css']
|
|
44
|
+
css: ['~/assets/css/main.css'],
|
|
45
45
|
})
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -113,7 +113,7 @@ The package can also be referenced as a string in the css property of your Nuxt
|
|
|
113
113
|
|
|
114
114
|
```ts [nuxt.config.ts]
|
|
115
115
|
export default defineNuxtConfig({
|
|
116
|
-
css: ['animate.css']
|
|
116
|
+
css: ['animate.css'],
|
|
117
117
|
})
|
|
118
118
|
```
|
|
119
119
|
|
|
@@ -121,15 +121,15 @@ export default defineNuxtConfig({
|
|
|
121
121
|
|
|
122
122
|
You can include external stylesheets in your application by adding a link element in the head section of your nuxt.config file. You can achieve this result using different methods. Note that local stylesheets can also be included this way.
|
|
123
123
|
|
|
124
|
-
You can manipulate the head with the [`app.head`](/docs/api/nuxt-config#head) property of your Nuxt configuration:
|
|
124
|
+
You can manipulate the head with the [`app.head`](/docs/4.x/api/nuxt-config#head) property of your Nuxt configuration:
|
|
125
125
|
|
|
126
126
|
```ts twoslash [nuxt.config.ts]
|
|
127
127
|
export default defineNuxtConfig({
|
|
128
128
|
app: {
|
|
129
129
|
head: {
|
|
130
|
-
link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }]
|
|
131
|
-
}
|
|
132
|
-
}
|
|
130
|
+
link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
133
|
})
|
|
134
134
|
```
|
|
135
135
|
|
|
@@ -137,11 +137,11 @@ export default defineNuxtConfig({
|
|
|
137
137
|
|
|
138
138
|
You can use the useHead composable to dynamically set a value in your head in your code.
|
|
139
139
|
|
|
140
|
-
:read-more{to="/docs/api/composables/use-head"}
|
|
140
|
+
:read-more{to="/docs/4.x/api/composables/use-head"}
|
|
141
141
|
|
|
142
142
|
```ts twoslash
|
|
143
143
|
useHead({
|
|
144
|
-
link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }]
|
|
144
|
+
link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }],
|
|
145
145
|
})
|
|
146
146
|
```
|
|
147
147
|
|
|
@@ -198,7 +198,7 @@ Alternatively, you can use the `css` property of your Nuxt configuration.
|
|
|
198
198
|
|
|
199
199
|
```ts twoslash [nuxt.config.ts]
|
|
200
200
|
export default defineNuxtConfig({
|
|
201
|
-
css: ['~/assets/scss/main.scss']
|
|
201
|
+
css: ['~/assets/scss/main.scss'],
|
|
202
202
|
})
|
|
203
203
|
```
|
|
204
204
|
|
|
@@ -234,11 +234,11 @@ export default defineNuxtConfig({
|
|
|
234
234
|
css: {
|
|
235
235
|
preprocessorOptions: {
|
|
236
236
|
scss: {
|
|
237
|
-
additionalData: '@use "~/assets/_colors.scss" as *;'
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
237
|
+
additionalData: '@use "~/assets/_colors.scss" as *;',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
242
|
})
|
|
243
243
|
```
|
|
244
244
|
|
|
@@ -248,11 +248,11 @@ export default defineNuxtConfig({
|
|
|
248
248
|
css: {
|
|
249
249
|
preprocessorOptions: {
|
|
250
250
|
sass: {
|
|
251
|
-
additionalData: '@use "~/assets/_colors.sass" as *\n'
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
251
|
+
additionalData: '@use "~/assets/_colors.sass" as *\n',
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
256
|
})
|
|
257
257
|
```
|
|
258
258
|
|
|
@@ -267,13 +267,12 @@ Vite has made available an [experimental option](https://vite.dev/config/shared-
|
|
|
267
267
|
You can enable this in your `nuxt.config`:
|
|
268
268
|
|
|
269
269
|
```ts
|
|
270
|
-
|
|
271
270
|
export default defineNuxtConfig({
|
|
272
271
|
vite: {
|
|
273
272
|
css: {
|
|
274
|
-
preprocessorMaxWorkers: true // number of CPUs minus 1
|
|
275
|
-
}
|
|
276
|
-
}
|
|
273
|
+
preprocessorMaxWorkers: true, // number of CPUs minus 1
|
|
274
|
+
},
|
|
275
|
+
},
|
|
277
276
|
})
|
|
278
277
|
```
|
|
279
278
|
|
|
@@ -298,14 +297,17 @@ You can leverage Vue SFC features to style your components with class and style
|
|
|
298
297
|
const isActive = ref(true)
|
|
299
298
|
const hasError = ref(false)
|
|
300
299
|
const classObject = reactive({
|
|
301
|
-
active: true,
|
|
302
|
-
'text-danger': false
|
|
300
|
+
'active': true,
|
|
301
|
+
'text-danger': false,
|
|
303
302
|
})
|
|
304
303
|
</script>
|
|
305
304
|
|
|
306
305
|
<template>
|
|
307
|
-
<div
|
|
308
|
-
|
|
306
|
+
<div
|
|
307
|
+
class="static"
|
|
308
|
+
:class="{ 'active': isActive, 'text-danger': hasError }"
|
|
309
|
+
/>
|
|
310
|
+
<div :class="classObject" />
|
|
309
311
|
</template>
|
|
310
312
|
```
|
|
311
313
|
|
|
@@ -315,13 +317,13 @@ const isActive = ref(true)
|
|
|
315
317
|
const error = ref(null)
|
|
316
318
|
|
|
317
319
|
const classObject = computed(() => ({
|
|
318
|
-
active: isActive.value && !error.value,
|
|
319
|
-
'text-danger': error.value && error.value.type === 'fatal'
|
|
320
|
+
'active': isActive.value && !error.value,
|
|
321
|
+
'text-danger': error.value && error.value.type === 'fatal',
|
|
320
322
|
}))
|
|
321
323
|
</script>
|
|
322
324
|
|
|
323
325
|
<template>
|
|
324
|
-
<div :class="classObject"
|
|
326
|
+
<div :class="classObject" />
|
|
325
327
|
</template>
|
|
326
328
|
```
|
|
327
329
|
|
|
@@ -332,7 +334,7 @@ const errorClass = ref('text-danger')
|
|
|
332
334
|
</script>
|
|
333
335
|
|
|
334
336
|
<template>
|
|
335
|
-
<div :class="[{ active: isActive }, errorClass]"
|
|
337
|
+
<div :class="[{ active: isActive }, errorClass]" />
|
|
336
338
|
</template>
|
|
337
339
|
```
|
|
338
340
|
|
|
@@ -344,9 +346,9 @@ const styleObject = reactive({ color: 'red', fontSize: '13px' })
|
|
|
344
346
|
</script>
|
|
345
347
|
|
|
346
348
|
<template>
|
|
347
|
-
<div :style="{ color: activeColor, fontSize: fontSize + 'px' }"
|
|
348
|
-
<div :style="[baseStyles, overridingStyles]"
|
|
349
|
-
<div :style="styleObject"
|
|
349
|
+
<div :style="{ color: activeColor, fontSize: fontSize + 'px' }" />
|
|
350
|
+
<div :style="[baseStyles, overridingStyles]" />
|
|
351
|
+
<div :style="styleObject" />
|
|
350
352
|
</template>
|
|
351
353
|
```
|
|
352
354
|
|
|
@@ -361,11 +363,13 @@ The binding will be dynamic, meaning that if the variable value changes, the sty
|
|
|
361
363
|
|
|
362
364
|
```vue
|
|
363
365
|
<script setup lang="ts">
|
|
364
|
-
const color = ref(
|
|
366
|
+
const color = ref('red')
|
|
365
367
|
</script>
|
|
366
368
|
|
|
367
369
|
<template>
|
|
368
|
-
<div class="text">
|
|
370
|
+
<div class="text">
|
|
371
|
+
hello
|
|
372
|
+
</div>
|
|
369
373
|
</template>
|
|
370
374
|
|
|
371
375
|
<style>
|
|
@@ -381,7 +385,9 @@ The scoped attribute allows you to style components in isolation. The styles dec
|
|
|
381
385
|
|
|
382
386
|
```vue
|
|
383
387
|
<template>
|
|
384
|
-
<div class="example">
|
|
388
|
+
<div class="example">
|
|
389
|
+
hi
|
|
390
|
+
</div>
|
|
385
391
|
</template>
|
|
386
392
|
|
|
387
393
|
<style scoped>
|
|
@@ -397,7 +403,9 @@ You can use [CSS Modules](https://github.com/css-modules/css-modules) with the m
|
|
|
397
403
|
|
|
398
404
|
```vue
|
|
399
405
|
<template>
|
|
400
|
-
<p :class="$style.red">
|
|
406
|
+
<p :class="$style.red">
|
|
407
|
+
This should be red
|
|
408
|
+
</p>
|
|
401
409
|
</template>
|
|
402
410
|
|
|
403
411
|
<style module>
|
|
@@ -451,9 +459,9 @@ export default defineNuxtConfig({
|
|
|
451
459
|
postcss: {
|
|
452
460
|
plugins: {
|
|
453
461
|
'postcss-nested': {},
|
|
454
|
-
'postcss-custom-media': {}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
462
|
+
'postcss-custom-media': {},
|
|
463
|
+
},
|
|
464
|
+
},
|
|
457
465
|
})
|
|
458
466
|
```
|
|
459
467
|
|
|
@@ -492,7 +500,7 @@ Use different styles for different layouts.
|
|
|
492
500
|
</style>
|
|
493
501
|
```
|
|
494
502
|
|
|
495
|
-
:read-more{to="/docs/guide/directory-structure/app/layouts"}
|
|
503
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app/layouts"}
|
|
496
504
|
|
|
497
505
|
## Third Party Libraries And Modules
|
|
498
506
|
|
|
@@ -509,7 +517,7 @@ Here are a few modules to help you get started:
|
|
|
509
517
|
- [Nuxt UI](https://ui.nuxt.com): A UI Library for Modern Web Apps
|
|
510
518
|
- [Panda CSS](https://panda-css.com/docs/installation/nuxt): CSS-in-JS engine that generates atomic CSS at build time
|
|
511
519
|
|
|
512
|
-
Nuxt modules provide you with a good developer experience out of the box, but remember that if your favorite tool doesn't have a module, it doesn't mean that you can't use it with Nuxt! You can configure it yourself for your own project. Depending on the tool, you might need to use a [Nuxt plugin](/docs/guide/directory-structure/plugins) and/or [make your own module](/docs/guide/going-further/modules). Share them with the [community](/modules) if you do!
|
|
520
|
+
Nuxt modules provide you with a good developer experience out of the box, but remember that if your favorite tool doesn't have a module, it doesn't mean that you can't use it with Nuxt! You can configure it yourself for your own project. Depending on the tool, you might need to use a [Nuxt plugin](/docs/4.x/guide/directory-structure/plugins) and/or [make your own module](/docs/4.x/guide/going-further/modules). Share them with the [community](/modules) if you do!
|
|
513
521
|
|
|
514
522
|
### Easily Load Webfonts
|
|
515
523
|
|
|
@@ -521,9 +529,9 @@ If you are using [UnoCSS](https://unocss.dev/integrations/nuxt), note that it co
|
|
|
521
529
|
|
|
522
530
|
### Transitions
|
|
523
531
|
|
|
524
|
-
Nuxt comes with the same `<Transition>` element that Vue has, and also has support for the experimental [View Transitions API](/docs/getting-started/transitions#view-transitions-api-experimental).
|
|
532
|
+
Nuxt comes with the same `<Transition>` element that Vue has, and also has support for the experimental [View Transitions API](/docs/4.x/getting-started/transitions#view-transitions-api-experimental).
|
|
525
533
|
|
|
526
|
-
:read-more{to="/docs/getting-started/transitions"}
|
|
534
|
+
:read-more{to="/docs/4.x/getting-started/transitions"}
|
|
527
535
|
|
|
528
536
|
### Font Advanced Optimization
|
|
529
537
|
|
|
@@ -558,7 +566,9 @@ export default defineNuxtConfig({
|
|
|
558
566
|
// start from the end of the array and go to the beginning
|
|
559
567
|
for (let i = css.length - 1; i >= 0; i--) {
|
|
560
568
|
// if it starts with 'entry', remove it from the list
|
|
561
|
-
if (css[i].startsWith('entry'))
|
|
569
|
+
if (css[i].startsWith('entry')) {
|
|
570
|
+
css.splice(i, 1)
|
|
571
|
+
}
|
|
562
572
|
}
|
|
563
573
|
}
|
|
564
574
|
},
|