extendPlugins 属性
extendPlugins 属性允许自定义 Nuxt 插件(options.plugins )。
-
类型:
Function -
默认值:
undefined
有时你可能想扩展插件或更改 Nuxt 创建的插件顺序。此函数接收一个插件 对象数组,并返回插件对象数组。
更改插件顺序的示例:
nuxt.config.js
export default {
extendPlugins(plugins) {
const pluginIndex = plugins.findIndex(
({ src }) => src === '~/plugins/shouldBeFirst.js'
)
const shouldBeFirstPlugin = plugins[pluginIndex]
plugins.splice(pluginIndex, 1)
plugins.unshift(shouldBeFirstPlugin)
return plugins
}
}
Edit this page on GitHub
Updated at Tue, Apr 14, 2026