---
title: "updateAppConfig"
description: "在运行时更新应用配置。"
canonical_url: "https://nuxt.zhcndoc.com/docs/3.x/api/utils/update-app-config"
---
# updateAppConfig

> 在运行时更新应用配置。

::note
使用深度赋值更新 [`app.config`](https://nuxt.zhcndoc.com/docs/3.x/directory-structure/app-config)。现有的（嵌套）属性将会保留。
::

## 用法

```js
import { updateAppConfig, useAppConfig } from '#imports'

const appConfig = useAppConfig() // { foo: 'bar' }

const newAppConfig = { foo: 'baz' }
updateAppConfig(newAppConfig)

console.log(appConfig) // { foo: 'baz' }
```

::read-more{to="https://nuxt.zhcndoc.com/docs/3.x/directory-structure/app-config"}
::

---

- [源码](https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/config.ts)


## Sitemap

See the full [sitemap](https://nuxt.zhcndoc.com/sitemap.md) for all pages.
