@element-plus/nuxt

中文文档
1.1.5发布于 2026/02/05MITTypeScriptES Module构建来源已验证近 30 天下载 8.2万

Element Plus module for Nuxt

原始使用文档
文档目录27 节
  1. Features
  2. Installation
  3. Configuration
  4. Usage
  5. Options
  6. importStyle
  7. themes
  8. icon
  9. installMethods
  10. namespace
  11. defaultLocale
  12. cache
  13. themeChalk
  14. globalConfig
  15. injectionID
  16. injectionZIndex
  17. appendTo
  18. components
  19. subComponents
  20. directives
  21. imports
  22. baseImports
  23. noStylesComponents
  24. include
  25. exclude
  26. Template
  27. Development

Element Plus Nuxt

Element Plus module for Nuxt

Features

  • Automatically import components and styles on demand.
  • Automatically import directives and styles on demand.
  • Automatically import icons from @element-plus/icons-vue.
  • Automatically import of ElMessage, ElNotification and other methods.
  • Automatically inject the ID_INJECTION_KEY and ZINDEX_INJECTION_KEY into Vue.
  • Automatically inject the teleport markup into the correct location in the final page HTML.

Installation

[!WARNING] Since the dayjs used internally by element-plus is not a JavaScript modules, in order to ensure that it can be converted into a JavaScript modules before startup, you need to add a .npmrc file to the root directory of the project and add the following configuration:

shamefully-hoist=true
node-linker=hoisted

Or install the dayjs dependency separately.

npx nuxi@latest module add element-plus
# or
npm i element-plus @element-plus/nuxt -D

Configuration

[!WARNING] At present, the method cannot automatically obtain the context, and you need to manually configure installMethods in the options.

export default defineNuxtConfig({
  modules: [
    '@element-plus/nuxt'
  ],
  elementPlus: { /** Options */ }
})

Usage

<template>
  <el-button @click="ElMessage('hello')">button</el-button>
  <ElButton :icon="ElIconEditPen" type="success">button</ElButton>
  <LazyElButton type="warning">lazy button</LazyElButton>
</template>

Reference Nuxt documentation and playground use.

Options

importStyle

  • Type: 'css' | 'scss' | boolean
  • Default: css

import style css or sass(scss) with components, disable automatically import styles with false.

themes

  • Type: array

A list of themes that require import styles automatically.

e.g. ['dark']

icon

  • Type: string | false
  • Default: ElIcon

Icon prefix name, disable automatically import icon with false.

installMethods

  • Type: array

List of methods that need to be installed.

e.g. ['ElLoading', 'ElMessage', 'ElMessageBox', 'ElNotification']

namespace

  • Type: string
  • Default: el

When you change the global namespace, you must change it here as well.

defaultLocale

  • Type: string

Replace default locale, you can find locale list here

e.g. 'zh-cn'

cache

  • Type: boolean
  • Default: false

Whether to cache the element-plus components and directives. Only effective in development mode.

If you enable this feature, you will get faster loading speed in development mode.

themeChalk

  • Type: object

Configure SCSS variables for generating custom themes. Only effective when importStyle is scss.

e.g.

{
  $colors: {
    primary: { base: 'rgba(107,33,168, 1)' }
  },
  dark: {
    $colors: {
      primary: { base: 'rgb(242, 216, 22)' }
    }
  }
}

globalConfig

  • Type: object

Set global configuration, such as modifying the default size and z-index of the component.

e.g. { size: 'small', zIndex: 3000 }

injectionID

  • Type: object
  • Default: { prefix: 1024, current: 0 }

Automatically inject the ID_INJECTION_KEY into Vue.

injectionZIndex

  • Type: object
  • Default: { current: 0 }

Automatically inject the Z_INDEX_INJECTION_KEY into Vue.

appendTo

  • Type: array

When you modify the append-to props in all based on ElTooltip components, you need to add the value here.

components

  • Type: array

If there are components that are not imported automatically from Element Plus, you need to add the component name here.

e.g. ['ElSubMenu']

subComponents

  • Type: object

A map of components that the definition file of subComponent is in its parent component.

directives

  • Type: object

If there are directives that are not imported automatically from Element Plus, you need to add the directive name here.

imports

  • Type: array

If you wish to add automatically import content from Element Plus, you can add it here.

e.g.

[
  ['useLocale', 'es/hooks/use-locale/index.mjs'],
  [['castArray', 'unique'], 'es/utils/arrays.mjs']
],

baseImports

  • Type: array

List of imports that will be imported whether if autoImports is disabled.

noStylesComponents

  • Type: array

When a component incorrectly loads styles, you need to add the component name here.

include

  • Type: array
  • Default: [ /\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.((c|m)?j|t)sx?$/]

Include files that need to automatically import styles.

exclude

  • Type: array
  • Default: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/]

Exclude files that do not require the automatic import of styles.

Template

element-plus-nuxt-starter

Development

  • Run pnpm i to install the dependencies.
  • Run pnpm dev:prepare to generate type stubs.
  • Run pnpm dev to start playground in development mode.
  • Run pnpm dev:build to build playground.
  • Run pnpm dev:start to locally preview playground.
  • Run pnpm build to build this project.

版本与发布记录

@element-plus/nuxt 共发布 17 个版本,首次发布于 2023/01/04;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.5latest2026/02/059 个月前
1.1.42025/07/131.3 年前
1.1.32025/06/071.4 年前
1.1.22025/05/091.5 年前
1.1.12024/12/181.9 年前
1.1.02024/11/022 年前

关于 @element-plus/nuxt 的常见问题

@element-plus/nuxt 是什么?

Element Plus module for Nuxt

如何安装 @element-plus/nuxt?

在项目目录运行 npm install @element-plus/nuxt,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@element-plus/icons-vue(>=0.2.6)、element-plus(>=2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@element-plus/nuxt 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@element-plus/nuxt 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@element-plus/nuxt 可以商用吗?

@element-plus/nuxt 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@element-plus/nuxt 的下载量有多少?

根据 npm 官方下载统计,@element-plus/nuxt 在 2026/10/14 – 2026/11/12 这 30 天内被下载 82,445 次,日均约 2,748 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@element-plus/nuxt 还在维护吗?

最新版本 1.1.5 发布于 2026/02/05(9 个月前);至今共发布 17 个版本,其中过去 12 个月发布了 1 个;首次发布于 2023/01/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。