Angular 7 - 生产模式:我无法使用 Tab 键浏览页面



我遇到了一个我真的无法解决的问题!当我在开发模式(ng-server(下运行我的angular 7项目时,我可以使用tab键浏览我的页面(表单、链接、按钮等(。当我运行ng-serve-prod并在本地(localhost(运行项目时,选项卡导航也可以工作。但奇怪的是,当我将生产构建放入服务器时,tab键停止工作。

我在这里留下我的angular.json文件,因为我最好的办法是这个问题与一些配置有关(只是不知道是哪一个(

我在谷歌上搜索了又一次,但找不到任何相关的东西。。。

{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"Marketplace": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
{
"glob": "**/*",
"input": "src/assets/ubrest",
"output": "assets"
},
"src/assets/ubrest/favicon.ico",
"src/.htaccess"
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/summernote/dist/summernote-lite.css",
"node_modules/owl.carousel/dist/assets/owl.carousel.css",
"node_modules/owl.carousel/dist/assets/owl.theme.default.css",  
"node_modules/fullpage.js/dist/jquery.fullpage.css",
"src/assets/ubrest/sass/styles.scss"        
],
"stylePreprocessorOptions": {
"includePaths": [
"src/assets/ubrest/sass"
]
},
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/summernote/dist/summernote-lite.js",
"node_modules/owl.carousel/dist/owl.carousel.min.js",
"node_modules/fullpage.js/dist/jquery.fullpage.min.js",
"node_modules/fullpage.js/dist/jquery.fullpage.extensions.min.js"
]
},
"configurations": {
"production": {
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "Marketplace:build",
"port": 8080
},
"configurations": {
"production": {
"browserTarget": "Marketplace:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "Marketplace:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/ng2-toastr/bundles/ng2-toastr.min.css",
"src/assets/sass/styles.scss"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"Marketplace-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "Rhizom Marketplace:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "Marketplace",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}

谢谢!

我可以看到你正在使用fullPage.js。库会覆盖选项卡功能,以便在某些情况下保持正确的布局。

为了测试这是否是您的问题,您可以尝试在控制台上调用:

$.fn.fullpage.destroy();

这将销毁fullPage.JS使用的所有JS处理程序,但将保留fullPage结构。

真正没有意义的是,你只有在生产中才有问题,而不是在开发中。

无论如何,我建议您将fullpage.js版本更新为最新版本。Fullpage.js3.X。它摆脱了jQuery,并通过选项卡功能解决了某些问题,正如您在其更改日志中看到的那样。

另外,请注意,您只需要包含fullPage.js一次,而且您要包含两次,这可能会导致问题:

"node_modules/fullpage.js/dist/jquery.fullpage.min.js",
"node_modules/fullpage.js/dist/jquery.fullpage.extensions.min.js"

只使用扩展名一个。

这很奇怪。我们有以现代angular构建的应用程序,但我们从未在任何可访问性审计中遇到过这个问题。你看过标签索引了吗?如果使用自定义组件,则可能需要将tabindex="0"分配给那些应该以键盘为焦点的元素。

相关内容

  • 没有找到相关文章

最新更新