nuxt add
Создание сущности в вашем приложении Nuxt.
Terminal
npx nuxt add <TEMPLATE> <NAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--force]
Arguments
| Argument | Description |
|---|---|
TEMPLATE | Specify which template to generate (options: <api|plugin|component|composable|middleware|layout|page|layer>) |
NAME | Specify name of the generated file |
Options
| Option | Default | Description |
|---|---|---|
--cwd=<directory> | . | Specify the working directory |
--logLevel=<silent|info|verbose> | Specify build-time log level | |
--force | false | Force override file if it already exists |
Модификаторы:
Некоторые шаблоны поддерживают дополнительные модификаторы флагов для добавления суффикса (например, .client или .get) к их имени.
Terminal
# Создает `/plugins/sockets.client.ts`
npx nuxt add plugin sockets --client
nuxt add component
- Флаги модификаторов:
--mode client|serverили--clientили--server
Terminal
# Создает `components/TheHeader.vue`
npx nuxt add component TheHeader
nuxt add composable
Terminal
# Создает `composables/foo.ts`
npx nuxt add composable foo
nuxt add layout
Terminal
# Создает `layouts/custom.vue`
npx nuxt add layout custom
nuxt add plugin
- Флаги модификаторов:
--mode client|serverили--clientили--server
Terminal
# Создает `plugins/analytics.ts`
npx nuxt add plugin analytics
nuxt add page
Terminal
# Создает `pages/about.vue`
npx nuxt add page about
Terminal
# Создает `pages/category/[id].vue`
npx nuxt add page "category/[id]"
nuxt add middleware
- Флаги модификаторов:
--global
Terminal
# Создает `middleware/auth.ts`
npx nuxt add middleware auth
nuxt add api
- Флаги модификаторов:
--method(может принятьconnect,delete,get,head,options,patch,post,putилиtrace) или, наоборот, вы можете напрямую использовать--get,--post, и другое.
Terminal
# Создает `server/api/hello.ts`
npx nuxt add api hello
nuxt add layer
Terminal
# Generates `layers/subscribe/nuxt.config.ts`
npx nuxt add layer subscribe