Appearance
Nuxt3 app.config.ts - APP 配置
Nuxt3 app.config.ts
应用程序配置文件提供运行时应用程序配置。它的扩展名可以是.ts
、.js
或.mjs
。
// app.config.ts
export default defineAppConfig({
foo: 'bar'
})
WARNING
不要把任何私密数据放在app.config
文件中。它将暴露给客户端。
定义 App Config
在app.config
文件中定义配置:
// app.config.ts
export default defineAppConfig({
theme: {
primaryColor: '#ababab'
}
})
使用useAppConfig
组合函数获取配置信息:
const appConfig = useAppConfig()
console.log(appConfig.theme)
类型接口
Nuxt 会尝试从app.config
中自动生成一个类型接口。
也可以手动输入app config:
// index.d.ts
declare module '@nuxt/schema' {
interface AppConfig {
/** Theme configuration */
theme: {
/** Primary app color */
primaryColor: string
}
}
}
// It is always important to ensure you import/export something when augmenting a type
export {}