# 模型配置路径使用 uid 而不是点号表示法

> Source: https://strapi.nodejs.cn/cms/migration/v4-to-v5/breaking-changes/model-config-path-uses-uid

🌐 Model config path uses uid instead of dot notation

在 Strapi 5 中，配置路径使用 `::` 表示法而不是点表示法来访问模型，将 `plugin.upload.somesetting` 改为 `plugin::upload.somesetting`。

🌐 In Strapi 5, configuration paths use `::` notation instead of dot notation to access models, changing `plugin.upload.somesetting` to `plugin::upload.somesetting`.

在 Strapi 5 中，要获取配置值，你需要使用 `config.get('plugin::upload.myconfigval')` 或 `config.get('api::myapi.myconfigval')`

🌐 In Strapi 5, to retrieve config values you will need to use `config.get('plugin::upload.myconfigval')` or `config.get('api::myapi.myconfigval')`

此页面是[重大更改数据库](/cms/migration/v4-to-v5/breaking-changes)的一部分，提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the [breaking changes database](/cms/migration/v4-to-v5/breaking-changes) and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

- Is this breaking change affecting plugins? Yes
- Is this breaking change automatically handled by a codemod? Partly
  - Codemod: [use-uid-for-config-namespace](https://github.com/strapi/strapi/blob/develop/packages/utils/upgrade/resources/codemods/5.0.0/use-uid-for-config-namespace.code.ts)

## 重大变更描述 {#breaking-change-description}

🌐 Breaking change description

**在 Strapi v4 中**

模型使用 `.` 表示法添加到配置中，如下所示：

🌐 Models are added to the configuration using `.` notation as follows:

```jsx
strapi.config.get('plugin.upload.somesetting');
if ( strapi.config.has('plugin.upload.somesetting') ) {
  strapi.config.set('plugin.upload.somesetting', false);
}
```

**在 Strapi 5 中**

模型通过使用 `::` 替换 `.` 的表示法添加到配置中，如下所示：

🌐 Models are added to the configuration using `::` replacing `.` notation as follows:

```jsx
strapi.config.get('plugin::upload.somesetting');
if ( strapi.config.has('plugin::upload.somesetting') ) {
  strapi.config.set('plugin::upload.somesetting', false);
}
```

## 迁移 {#migration}

🌐 Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

🌐 This section regroups useful notes and procedures about the introduced breaking change.

### 注意 {#notes}

🌐 Notes

- 如果一个 API 有配置，也应该使用 `strapi.config.get(’api::myapi.myconfigval’)` 进行访问。
- 'plugin' 命名空间目前有临时支持，但会有弃用警告。这意味着引用 `plugin.upload.somesetting` 会在服务器日志中发出警告，并改为检查 `plugin::upload.somesetting`。
- 已经创建了一个代码修改工具来帮助重构用户代码中的字符串，将 `plugin.` 或 `api.` 替换为 `plugin::` 和 `api::`。

### 手动操作 {#manual-procedure}

🌐 Manual procedure

在大多数情况下，codemod 会自动处理更改。

🌐 A codemod will automatically handle the change in most cases.

如果 codemod 无法自动处理更改，用户需要手动替换所有字符串以定位新的配置路径。

🌐 In cases were the codemod does not automatically handle the change, users will need to manually replace all their strings to target the new config paths.
