Javascript 服务人员可用事件未使用angular 7触发
我已经在angular 7中创建了应用程序,并提供了PWA支持。其中,我用swUpdate创建了新的更新弹出窗口。早些时候,它的工作正常,并向我显示新的更新弹出窗口,一旦我上传了新的服务器构建。但是,它不起作用 这里是我的代码Javascript 服务人员可用事件未使用angular 7触发,javascript,angular,angular7,service-worker,progressive-web-apps,Javascript,Angular,Angular7,Service Worker,Progressive Web Apps,我已经在angular 7中创建了应用程序,并提供了PWA支持。其中,我用swUpdate创建了新的更新弹出窗口。早些时候,它的工作正常,并向我显示新的更新弹出窗口,一旦我上传了新的服务器构建。但是,它不起作用 这里是我的代码 constructor() { this.swUpdate.available.subscribe(event => { console.log(event); this.promptUser(); }); if (
constructor() {
this.swUpdate.available.subscribe(event => {
console.log(event);
this.promptUser();
});
if (this.swUpdate.isEnabled) {
interval(2 * 60 * 60).subscribe(() => this.swUpdate.checkForUpdate()
.then(() => console.log('checking for updates')));
}
}
promptUser() {
this.swUpdate.activateUpdate().then(() => {
location.reload();
});
}
这是我的package.json文件
{
"name": "app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod --configuration=dev",
"build:dev": "ng build --prod --configuration=dev",
"build:staging": "ng build --prod --configuration=staging",
"build:prod": "ng build --prod --configuration=production",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.9",
"@angular/cdk": "^7.3.1",
"@angular/common": "^7.2.3",
"@angular/compiler": "^7.2.3",
"@angular/core": "^7.2.3",
"@angular/fire": "^5.1.1",
"@angular/flex-layout": "^7.0.0-beta.24",
"@angular/forms": "^7.2.3",
"@angular/http": "^7.2.3",
"@angular/material": "^7.3.1",
"@angular/platform-browser": "^7.2.3",
"@angular/platform-browser-dynamic": "^7.2.3",
"@angular/pwa": "^0.10.7",
"@angular/router": "^7.2.3",
"@angular/service-worker": "^7.2.3",
"@ng-bootstrap/ng-bootstrap": "^4.0.2",
"angular-font-awesome": "^3.1.2",
"angular-moment-timezone": "^1.7.1",
"angular2-cookie": "^1.2.6",
"angular2-cookie-law": "^6.2.0",
"angular2-toaster": "^7.0.0",
"angular7-data-table": "^1.0.13",
"bootstrap": "^4.2.1",
"core-js": "^2.6.3",
"exceljs": "^2.0.1",
"file-saver": "^2.0.2",
"firebase": "^5.8.3",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"jw-angular-social-buttons": "^1.0.0",
"moment": "^2.24.0",
"moment-timezone": "^0.5.23",
"ng-connection-service": "^1.0.4",
"ng-http-loader": "^3.2.0",
"ng-recaptcha": "^4.2.1",
"ng2-validation": "^4.2.0",
"ng6-toastr-notifications": "^1.0.4",
"ngx-cookie-service": "^2.1.0",
"ngx-infinite-scroll": "^6.0.1",
"ngx-slick": "^0.2.1",
"ngx-slick-carousel": "^0.4.4",
"node-sass": "^4.13.0",
"rxjs": "^6.4.0",
"rxjs-compat": "^6.4.0",
"slick-carousel": "^1.8.1",
"stylelint": "^9.10.1",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.10.7",
"@angular/cli": "^7.3.0",
"@angular/compiler-cli": "^7.2.3",
"@angular/language-service": "^7.2.3",
"@types/jasmine": "^2.8.16",
"@types/jasminewd2": "^2.0.6",
"@types/moment": "^2.13.0",
"@types/node": "^12.0.2",
"codelyzer": "~4.2.1",
"husky": "^1.3.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~3.1.6"
},
"browser": {
"fs": false,
"path": false,
"os": false,
"crypto": false,
"stream": false,
"http": false,
"tls": false,
"zlib": false,
"https": false,
"net": false
}
}
请让我知道,如果有任何对此有任何建议。它真的需要。你能告诉我你犯了什么错误吗?我没有任何错误。在什么都没有发生之后,只需控制台检查更新文本。一旦我有硬刷新标签最新版本将被加载。一旦我关闭选项卡并重新打开它加载的旧构建数据。你能告诉我你得到了什么错误吗?我没有得到任何错误。在什么都没有发生之后,只需控制台检查更新文本。一旦我有硬刷新标签最新版本将被加载。一旦我关闭了选项卡并重新打开了它加载的旧构建数据。