javascript - Angular 7 - 生产模式 : I can't navigate through page using the tab key

标签 javascript angular server navigation accessibility

我遇到了一个我真的无法弄清楚的问题!当我在开发模式 (ng serve) 上运行我的 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.js 版本更新到最新版本。 Fullpage.js 3.X.正如您在其 changelog 中看到的那样,它摆脱了 jQuery 并解决了选项卡功能的某些问题。 .

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

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

仅使用扩展程序。

关于javascript - Angular 7 - 生产模式 : I can't navigate through page using the tab key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53636486/

相关文章:

java - 设置 WebLogic Server 11g (10.3.6) : Native Library to read the password securely from commandline is not found 时出错

c - Socket编程——服务端内容写入客户端(write())

javascript - 使用循环创建一个div

javascript - Angular2 http.get 代码不起作用

javascript - Angular 2 typescript 引用路径

angular - 将 'on subscribe' 回调附加到 observable

java - 如何解决此错误 : HTTP Status 500 - Internal Server Error

javascript - 属性声明中无法进行数学运算?

javascript - 无法发送多个表单字段 formdata dropzone.js

Javascript 为什么要将函数原型(prototype)的构造函数分配给函数本身? Programmer.prototype.constructor = 程序员