0

我在这个网站的部分页面中使用了分页。我按照它的指示,现在下面是我在项目中的相关文件:

app.item.html

<mat-paginator [length]="100"
               [pageSize]="10"
               [pageSizeOptions]="[5, 10, 25, 100]">
</mat-paginator>

应用程序.item.ts

import {Component} from '@angular/core';



@Component({

  templateUrl: './app.item-list.html',
  styleUrls: ['table-pagination-example.css']

})

export class ItemListComponent {

}

包.json

{
  "name": "art-shop",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/schematics": "0.0.46",
    "@angular/animations": "^5.1.3",
    "@angular/cdk": "^5.0.4",
    "@angular/common": "^5.1.3",
    "@angular/compiler": "^5.1.3",
    "@angular/core": "^5.1.3",
    "@angular/forms": "^5.1.3",
    "@angular/http": "^5.1.3",
    "@angular/material": "^5.0.4",
    "@angular/platform-browser": "^5.1.3",
    "@angular/platform-browser-dynamic": "^5.1.3",
    "@angular/router": "^5.1.3",
    "core-js": "^2.4.1",
    "rxjs": "^5.4.1",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "^1.6.4",
    "@angular/compiler-cli": "^5.1.3",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.4",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~9.3.0",
    "codelyzer": "~4.0.2",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "npm-update-all": "^1.0.1",
    "protractor": "~5.2.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "^2.4.2"
  }
}

app.module.ts

@NgModule({
  declarations: [
    AppComponent,
    headerComponent,
    footerComponent,
    registerSellerComponent,
    ProductListComponent,
    ItemListComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    MatTableModule,
    MatPaginatorModule

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {
}

web-animations用这个命令安装:npm install --save web-animations-js

并放入<script src="../node_modules/web-animations-js/web-animations.min.js"></script>我的index.html未注释的

import 'web-animations-js'

在我的polyfill.ts但不仅分页不起作用而且就像那样,而且我在我的浏览器中看到这个错误:

Loading failed for the <script> with source “http://localhost:4200/node_modules/web-animations-js/web-animations.min.js”.
4

2 回答 2

0

您不必. _ 它应该已经由.scriptweb-animations-jspolyfills.ts

于 2018-01-17T18:33:47.233 回答
0

node_modules 未与您的应用程序一起部署。

在 index.html 中,将 URL 替换为 Web 动画库的 CDN:

<script src="https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.3.1/web-animations.min.js"></script>
于 2018-01-17T12:43:56.107 回答