透過 100 多個技巧提示學習 Nuxt!

arco-design-nuxt-module
arco-design-nuxt-module

用於 Arco Design Vue 的 Nuxt 模組。自動導入元件、圖示等。

npm versionnpm downloadsLicense

用於 Arco Design Vue 的 Nuxt 模組。自動導入元件、圖示等。

功能特色

  • ✨ 自動導入元件
  • ✨ 自動導入圖示
  • ✨ 自動導入 Message、Notification
  • ✨ 自動導入 hooks
  • ✨ 自動導入 locale hooks
  • 🔹 支援自訂前綴

快速開始設定

  1. 新增 arco-design-nuxt-module 依賴到你的專案
npx nuxi@latest module add arco-design-nuxt-module

!NOTE 如果你尚未安裝 @arco-design/web-vue,請先安裝

pnpm install @arco-design/web-vue

  1. 新增 arco-design-nuxt-modulenuxt.config.tsmodules 區塊
export default defineNuxtConfig({
  modules: [
    'arco-design-nuxt-module'
  ]
})

選項

如果你需要自訂模組,你可以在 nuxt.config.ts 中設定 arco

範例

export default defineNuxtConfig({
  arco: {
    importPrefix: 'A',
    hookPrefix: 'Arco',
    locales: ['getLocale'],
    localePrefix: 'Arco',
  },
})

完整類型

interface Options {
  /**
   * A list of components that need to be automatically imported.
   *
   * @default * all component from '@arco-design/web-vue/'
   *
   * @example
   * ```ts
   *  ['Button']
   * ```
   */
  components: false | string[]

  /**
   * Prefix of the component name.
   *
   * @default 'A'
   */
  componentPrefix: string

  /**
   * A list of icons component that need to be automatically imported.
   *
   * @default * all icons from '@arco-design/web-vue/(es|lib)/icon'
   *
   * @example
   * ```ts
   *  ['IconArrowDown']
   * ```
   */
  icons: false | string[]

  /**
   * Prefix of the icon component name.
   *
   * @default ''
   */
  iconPrefix: string

  /**
   * A map of components that the definition file of subComponent is in its parent component.
   * Normally, you don't need to set it.
   */
  subComponents: Record<string, string[]>

  /**
   * A list of imports(with style auto import) that need to be automatically imported.
   *
   * @default
   * ```ts
   *  ['Notification', 'Message']
   * ```
   */
  imports: false | ('Notification' | 'Message')[]

  /**
   * Prefix of the import name.
   *
   * @default ''
   */
  importPrefix: string

  /**
   * When you need to add automatically import locale function from Arco Design Vue, you can add it here.
   *
   * @default false
   *
   * @example
   * ```ts
   *  ['useLocale', 'getLocale', 'addI18nMessages']
   * ```
   *
   */
  locales: false | ('useLocale' | 'getLocale' | 'addI18nMessages')[]

  /**
   * Prefix of the locale name.
   *
   * @default ''
   *
   * @example
   * 'A' -> 'useALocale'
   */
  localePrefix: string

  /**
   * When you need to add automatically import hooks from Arco Design Vue, you can add it here.
   *
   * @default
   * ```ts
   * ['useFormItem']
   * ```
   *
   */
  hooks: false | ('useFormItem')[]

  /**
   * Prefix of the hook name.
   *
   * @default ''
   *
   * @example 'A' -> 'useAFormItem'
   */
  hookPrefix: string

  /**
   * import style css or less with components
   *
   * @default 'css'
   *
   * Disable automatically import styles with `false`
   */
  importStyle: 'css' | 'less' | boolean

  /**
   * use arco design theme.
   *
   * @default undefined
   *
   * @example '@arco-themes/vue-digitforce'
   *
   * It will full import the theme style file(index.less or css/arco.css)
   *
   * Recommended just directly import index.less or css/arco.css in your project and disable `importStyle` rather than using this option
   *
   * for more detail about theme, see https://arco.design/docs/designlab/use-theme-package
   */
  theme: string

  /**
   * A list of component names that have no styles, so resolving their styles file should be prevented
   *
   * @default
   * ```ts
   * ['ConfigProvider', 'Icon']
   * ```
   */
  noStylesComponents: string[]

  /**
   * import from es or lib
   *
   * @default 'es'
   *
   */
  importFrom: 'es' | 'lib'
}

完成了!你現在可以在你的 Nuxt 應用程式中使用 Arco Design Nuxt 模組了 ✨

其他

貢獻者

感謝