# @davidlj95/ngx-meta 中文文档

规范地址：https://npmcn.com/package/%40davidlj95/ngx-meta/

版本：22\.0\.0
npm 元数据更新时间：2026-10-26T01:33:09.721Z
中文译文更新时间：2026-11-12T09:25:44.490Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40davidlj95/ngx-meta
原文对照：https://npmcn.com/package/%40davidlj95/ngx-meta/?lang=original
项目主页：https://ngx-meta.dev/
源码仓库：https://github.com/davidlj95/ngx

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：386 kB，72 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：1 个
- peer 依赖：@angular/core ^22 \|\| ^21 \|\| ^20，@angular/common ^22 \|\| ^21 \|\| ^20，@angular/router ^22 \|\| ^21 \|\| ^20
- 首次发布：2023-11-23T14:16:33.755Z
- 最新版本发布：2026-10-26T01:33:09.408Z
- 近 30 天下载量：2621（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：91（近 12 个月 3 个）

## 中文简介

设置您的 Angular 网站的元数据: 标准元标记, Open Graph, Twitter Cards, JSON- LD 结构化数据等等. 支持SSR(和Angular Universal). 使用服务。 使用路由数据. 立刻装好

## 安装

```sh
npm install @davidlj95/ngx-meta
```

也可以使用：`pnpm add @davidlj95/ngx-meta`、`yarn add @davidlj95/ngx-meta`、`bun add @davidlj95/ngx-meta`

## README

![<ngx-meta/> for Angular](https://npmcn.com/package/%40davidlj95/docs/content/images/logo.png)

[![Angular](https://img.shields.io/badge/Works_with-Angular_v15--v22-f11653?logo=angular&logoColor=white&link=https%3A%2F%2Fangular.dev%2F)](https://angular.dev/) [![Supports Angular SSR/Universal](https://custom-icon-badges.demolab.com/badge/Supports-Angular_SSR%2FUniversal-blue.svg?logo=angular-universal&link=https%3A%2F%2Fangular.dev%2Fguide%2Fssr)](https://angular.dev/guide/ssr)

[![NPM Downloads](https://img.shields.io/npm/dt/%40davidlj95%2Fngx-meta?logo=npm&label=NPM%20downloads&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40davidlj95%2Fngx-meta)](https://www.npmjs.com/package/@davidlj95/ngx-meta) [![NPM License](https://img.shields.io/npm/l/%40davidlj95%2Fngx-meta?logo=npm&label=License&link=https%3A%2F%2Fgithub.com%2Fdavidlj95%2Fngx%2Fblob%2Fmain%2Fprojects%2Fngx-meta%2Fsrc%2FLICENSE)](https://github.com/davidlj95/ngx/blob/main/projects/ngx-meta/src/LICENSE) [![NPM Version](https://img.shields.io/npm/v/%40davidlj95%2Fngx-meta?logo=npm&label=Latest%20version&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40davidlj95%2Fngx-meta)](https://www.npmjs.com/package/@davidlj95/ngx-meta) [![CI/CD workflow](https://github.com/davidlj95/ngx/actions/workflows/cicd.yml/badge.svg)](https://github.com/davidlj95/ngx/actions/workflows/cicd.yml) [![Codecov](https://codecov.io/gh/davidlj95/ngx/graph/badge.svg)](https://codecov.io/gh/davidlj95/ngx) [![GitHub last commit (branch)](https://img.shields.io/github/last-commit/davidlj95/ngx/main?logo=github&label=Last%20commit&link=https%3A%2F%2Fgithub.com%2Fdavidlj95%2Fngx%2Fcommits%2Fmain%2F)](https://github.com/davidlj95/ngx/commits/main/)

[![Coded in Typescript](https://img.shields.io/badge/Coded_in-TypeScript-007ACC?logo=typescript&logoColor=white&link=https%3A%2F%2Fwww.typescriptlang.org)](https://www.typescriptlang.org/) [![Git](https://img.shields.io/badge/VCS-Git-f05032?logo=git&logoColor=f05032&link=https%3A%2F%git-scm.com%2F)](https://git-scm.com/) [![GitHub](https://img.shields.io/badge/Repository_hosted_in-GitHub-181717?logo=github&logoColor=181717&link=https%3A%2F%github.com%2F)](https://github.com/) [![Package manager: pnpm](https://img.shields.io/badge/Package_manager-pnpm-f69220?logo=pnpm&link=https%3A%2F%2Fpnpm.io%2F)](https://pnpm.io/) [![Unit tests with Jasmine](https://img.shields.io/badge/Unit_tests_with-Jasmine-8A4182?logo=Jasmine&logoColor=white&link=https%3A%2F%2Fjasmine.github.io)](https://jasmine.github.io/) [![Unit tests ran by Karma](https://custom-icon-badges.demolab.com/badge/Unit_tests_ran_by-Karma-42beae.svg?logo=karma-runner&link=https%3A%2F%2Fkarma-runner.github.io)](https://karma-runner.github.io/) [![E2E tests with Cypress](https://img.shields.io/badge/E2E_tests_with-Cypress-69D3A7?logo=cypress&link=https%3A%2F%2Fwww.cypress.io)](https://www.cypress.io/) [![Code coverage with Codecov](https://img.shields.io/badge/Code_coverage_with-Codecov-F01F7A?logo=codecov&logoColor=F01F7A&link=https%3A%2F%2F.codecov.io)](https://codecov.io/) [![Linted with ESLint](https://img.shields.io/badge/Linted_with-ESLint-3A33D1?logo=eslint&logoColor=white&link=https%3A%2F%2Feslint.org)](https://eslint.org/) [![Formatted with Prettier](https://img.shields.io/badge/Formatted_with-prettier-1A2C34?logo=prettier&logoColor=F7BA3E&link=https%3A%2F%2Fprettier.io)](https://prettier.io/) [![Commits follow Conventional Commits convention](https://img.shields.io/badge/Commits_convention-Conventional_Commits-FE5196?logo=conventionalcommits&logoColor=white&link=https%3A%2F%2Fconventionalcommits.org)](https://conventionalcommits.org/) [![Git hooks with Husky](https://img.shields.io/badge/Git_hooks_with-Husky%F0%9F%90%B6-1a1a1e?link=https%3A%2F%2Ftypicode.github.io%2Fhusky%2F)](https://typicode.github.io/husky/) [![GitHub Actions](https://img.shields.io/badge/CI%2FCD%20with-GitHub_Actions-2088FF?logo=githubactions&logoColor=2088FF&link=https%3A%2F%github.com%2Ffeatures%2Factions)](https://github.com/features/actions) [![Released with Semantic Release](https://img.shields.io/badge/Released_with-Semantic_Release-e10079?logo=semantic-release&link=https%3A%2F%2Fgithub.com%2Fsemantic-release%2Fsemantic-release)](https://github.com/semantic-release/semantic-release) [![Dependencies updated with Renovate](https://img.shields.io/badge/Dependencies_updated_with-Renovate-1a1f6c?logo=renovate&link=https%3A%2F%2Frenovatebot.com)](https://renovatebot.com/) [![Docs with Material for Mkdocs](https://img.shields.io/badge/Docs_with-Material_for_Mkdocs-526CFE?logo=materialformkdocs&logoColor=white&link=https%3A%2F%2Fsquidfunk.github.io%2Fmkdocs-material%2F)](https://squidfunk.github.io/mkdocs-material/) [![API Report/Docs with API Extractor](https://custom-icon-badges.demolab.com/badge/API_Report_&_Docs_with-API_Extractor-383938.svg?logo=api-extractor&link=https%3A%2F%2Fapi-extractor.com%2F)](https://api-extractor.com/) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/davidlj95/ngx/blob/main/CODE_OF_CONDUCT.md)

设置您的 Angular 站点的元数据: 标准元标记, 打开图形, 推特卡,JSON-LD结构数据等. 支持SSR(和Angular Universal). 使用服务。 使用路由数据. 立刻装好

## 动机

你有一个很好的角力网站。 您想要改进它的 SEO 并决定在您的页面中添加一些元数据 。 您也可以启用 [服务器侧面渲染( SSR)](https://angular.dev/guide/ssr) 所以当搜索引擎访问您的站点时,元数据元素已经存在于服务器返回的HTML中. 你开始加好 `<meta name="description">` 描述您的主页。 然后,打开图元数据像 `<meta property="og:title">` [用于定制社会卡/链接预览](https://www.freecodecamp.org/news/what-is-open-graph-and-how-can-i-use-it-for-my-website/)。您将使用 [角质 `Meta` APIs 密码](https://angular.dev/api/platform-browser/Meta) 插入到您的 DOM。 目前为止一切都很好

现在,您想要为您网站的另一页设置元数据QQ

呼吁 [角质 `Meta` APIs 密码](https://angular.dev/api/platform-browser/Meta) 开始出现在很多地方。 指定对象文字 `<meta>` 定义像兔子一样繁衍 在更改页面时,您还必须确保网页上的元数据在访问另一个网页时不会停留在那里。 开始有点乏味了

如果有办法方便地指定元数据的话 我希望每个页面都以宣示的方式 忘记它 那你来对地方了 这个图书馆一定会帮你的

## 开始探索

### 新用户

首先,欢迎

想知道为什么这个图书馆 而不是另一个? 看看这个 [为什么](https://ngx-meta.dev/why/)也许,最有趣的部分是 [**特性**](https://ngx-meta.dev/why/features/) 财务报告和审定财务报表 [**比较**](https://ngx-meta.dev/why/comparison/) 页面.

供奉亲信们[_就是这样_](https://knowyourmeme.com/memes/this-is-the-way), (中文(简体) ), [**开始吧** ⚡️](https://ngx-meta.dev/get-started/)

### 现有用户

看一下向导 以更新你的知识。 如关于按程序设置元数据 [**使用服务**](https://ngx-meta.dev/guides/set-metadata-using-service/)以申报的方式 [**使用路由数据**](https://ngx-meta.dev/guides/set-metadata-using-routing/)或如何实现 [**元数据值 JSON**](https://ngx-meta.dev/guides/metadata-values-json/) 是形状的.

更进一步:

-   [**设置默认元数据**](https://ngx-meta.dev/guides/defaults/) 所有页面的值
-   [**设置 URL 分辨率**](https://ngx-meta.dev/guides/url-resolution/) 以使用相对的 URL 但获得绝对 URL 作为元数据值
-   [**格式化页面标题**](https://ngx-meta.dev/guides/title-formatting/) 对所有页面标题应用一致的格式
-   [**稍后装入元数据**](https://ngx-meta.dev/guides/late-loading-modules/) 以减小主捆绑大小
-   [**提供您的自定义元数据管理器**](https://ngx-meta.dev/guides/manage-your-custom-metadata/)
-   [**精细选择元数据元素**](https://ngx-meta.dev/guides/custom-metadata-providers-selection/) 你有兴趣。 其余的不会在你包里

你是在寻找 [**API 参考**](https://ngx-meta.dev/api/ngx-meta/)? 吗?

如果你看到一些腐烂 想要修复它们,看看 **移徙** 节次 [文件站点](https://ngx-meta.dev/)

## 常见问题

### @davidlj95/ngx-meta 是什么？

设置您的 Angular 网站的元数据: 标准元标记, Open Graph, Twitter Cards, JSON- LD 结构化数据等等\. 支持SSR\(和Angular Universal\)\. 使用服务。 使用路由数据\. 立刻装好

### 如何安装 @davidlj95/ngx-meta？

在项目目录运行 npm install @davidlj95/ngx-meta，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@angular/core（^22 \|\| ^21 \|\| ^20）、@angular/common（^22 \|\| ^21 \|\| ^20）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @davidlj95/ngx-meta 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @davidlj95/ngx-meta 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @davidlj95/ngx-meta 可以商用吗？

@davidlj95/ngx-meta 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @davidlj95/ngx-meta 的下载量有多少？

根据 npm 官方下载统计，@davidlj95/ngx-meta 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,621 次，日均约 87 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @davidlj95/ngx-meta 还在维护吗？

最新版本 22\.0\.0 发布于 2026/10/26（17 天前）；至今共发布 91 个版本，其中过去 12 个月发布了 3 个；首次发布于 2023/11/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

