Arco Design Vue 的 Nuxt 模块。自动导入组件、图标等。
功能
- ✨ 自动导入组件
- ✨ 自动导入图标
- ✨ 自动导入 Message、Notification
- ✨ 自动导入 hooks
- ✨ 自动导入本地化 hooks
- 🔹 支持自定义上述前缀
快速设置
- 将
arco-design-nuxt-module
依赖项添加到您的项目中(@arco-design/web-vue
您的项目中也需要)
# Using pnpm
pnpm add -D arco-design-nuxt-module
# Using yarn
yarn add --dev arco-design-nuxt-module
# Using npm
npm install --save-dev arco-design-nuxt-module
- 将
arco-design-nuxt-module
添加到nuxt.config.ts
文件的modules
部分
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(theme.less or css/arco.css)
*
* 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 模块 ✨
其他
鸣谢
感谢