ngx-cookie 项目使用教程

ngx-cookie 项目使用教程

ngx-cookieImplementation of Angular 1.x $cookies service to Angular 2项目地址:https://gitcode.com/gh_mirrors/ng/ngx-cookie

1. 项目的目录结构及介绍

ngx-cookie 项目的目录结构如下:

ngx-cookie/
├── src/
│   ├── lib/
│   │   ├── cookie.service.ts
│   │   ├── cookie.service.spec.ts
│   │   ├── index.ts
│   ├── public_api.ts
├── package.json
├── tsconfig.json
├── tsconfig.spec.json
├── tslint.json

目录结构介绍

  • src/: 源代码目录。
    • lib/: 包含主要的库文件。
      • cookie.service.ts: 核心的 Cookie 服务文件。
      • cookie.service.spec.ts: Cookie 服务的测试文件。
      • index.ts: 库的入口文件。
    • public_api.ts: 公共 API 入口文件。
  • package.json: 项目的依赖和脚本配置文件。
  • tsconfig.json: TypeScript 编译配置文件。
  • tsconfig.spec.json: TypeScript 测试配置文件。
  • tslint.json: TSLint 配置文件。

2. 项目的启动文件介绍

项目的启动文件主要是 src/public_api.ts,它是整个库的入口文件,负责导出库的主要功能。

/* src/public_api.ts */

/*
 * Public API Surface of ngx-cookie
 */

export * from './lib/cookie.service';

启动文件介绍

  • public_api.ts: 导出 cookie.service,使得其他项目可以通过 ngx-cookie 包导入 CookieService

3. 项目的配置文件介绍

package.json

package.json 文件包含了项目的依赖、脚本和其他元数据。

{
  "name": "ngx-cookie",
  "version": "0.0.1",
  "peerDependencies": {
    "@angular/common": "^6.0.0-rc.0 || ^6.0.0",
    "@angular/core": "^6.0.0-rc.0 || ^6.0.0"
  },
  "main": "bundles/ngx-cookie.umd.js",
  "module": "fesm5/ngx-cookie.js",
  "es2015": "fesm2015/ngx-cookie.js",
  "esm5": "esm5/ngx-cookie.js",
  "esm2015": "esm2015/ngx-cookie.js",
  "fesm5": "fesm5/ngx-cookie.js",
  "fesm2015": "fesm2015/ngx-cookie.js",
  "typings": "ngx-cookie.d.ts",
  "metadata": "ngx-cookie.metadata.json",
  "sideEffects": false,
  "dependencies": {
    "tslib": "^1.9.0"
  }
}

tsconfig.json

tsconfig.json 文件定义了 TypeScript 编译的配置。

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

tslint.json

tslint.json 文件定义了代码风格和质量检查的配置。

{
  "rules": {
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "curly": true,
    "

ngx-cookieImplementation of Angular 1.x $cookies service to Angular 2项目地址:https://gitcode.com/gh_mirrors/ng/ngx-cookie

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

支然苹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值