Angular 2+项目不接受外部js文件

时间:2018-06-17 06:01:45

标签: javascript node.js angular typescript angular5

您好我从themeforest购买了一个主题。它不是有角度的2+主题。 我试图在我的角度项目中使用主题我几乎阅读所有关于在角项目中包含外部js文件的文档我使用了很多策略但是没有工作

 <!doctype html>
<html lang="tr">

    <head>
      <meta charset="UTF-8">
      <meta name="keywords"
            content="Tercüme"/>
      <title>İlksen Tercüme</title>
      <base href="/">
      <link rel="stylesheet" type="text/css" href="./assets/theme/fonts/flaticon.css">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" type="text/css" href="./assets/theme/css/style.css">
      <link rel="stylesheet" type="text/css" href="./assets/theme/css/responsive.css">
    </head>

    <body>
    <div class="preloader"></div>
    <app-root></app-root>
    <div class="scroll-to-top scroll-to-target" data-target="html"><span class="fa fa-angle-up"></span></div>

    <!-- THEME JAVASCRIPT FILES -->
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCRvBPo3-t31YFk588DpMYS6EqKf-oGBSI"></script>
    <script src="./assets/theme/assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="./assets/theme/assets/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/jquery.themepunch.tools.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/jquery.themepunch.revolution.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.actions.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.carousel.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.kenburn.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.layeranimation.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.migration.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.navigation.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.parallax.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.slideanims.min.js"></script>
    <script src="./assets/theme/assets/revolution/js/extensions/revolution.extension.video.min.js"></script>
    <script src="./assets/theme/assets/gmaps.js"></script>
    <script src="./assets/theme/assets/map-helper.js"></script>
    <script src="./assets/theme/assets/jquery-validation/dist/jquery.validate.min.js"></script>
    <script src="./assets/theme/assets/owl/owl.carousel.min.js"></script>
    <script src="./assets/theme/assets/nouislider/nouislider.js"></script>
    <script src="./assets/theme/assets/bootstrap-touch-spin/jquery.bootstrap-touchspin.js"></script>
    <script src="./assets/theme/assets/isotope.js"></script>
    <script src="./assets/theme/assets/masterslider/masterslider.min.js"></script>
    <script src="./assets/theme/assets/bxslider/dist/jquery.bxslider.min.js"></script>
    <script src="./assets/theme/assets/chartjs/dist/Chart.min.js"></script>
    <script src="./assets/theme/assets/jquery-circle-progress-1.1.2/dist/circle-progress.js"></script>
    <script src="./assets/theme/assets/morris.js-master/morris.min.js"></script>
    <script src="./assets/theme/assets/raphael-master/raphael.min.js"></script>
    <script src="./assets/theme/assets/Magnific-Popup-master/dist/jquery.magnific-popup.min.js"></script>
    <script src="./assets/theme/assets/waypoints.min.js"></script>
    <script src="./assets/theme/assets/jquery.counterup.min.js"></script>
    <script src="./assets/theme/assets/wow.min.js"></script>
    <script src="./assets/theme/js/jquery.mixitup.min.js"></script>
    <script src="./assets/theme/js/custom.js"></script>
    <!-- // -->

    </body>

    </html>

这是我的index.html文件

还尝试从angular.cli文件导入这些js文件 还尝试从app.component.ts导入这些文件并使用构造函数

调用

什么都没有帮助

但是css文件只能解决js文件问题

我该如何解决这个问题?

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "my-new-project"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "./assets/styles.scss"
      ],
      "scripts": [
        "./assets/scripts.js",
        "./assets/theme/js/custom.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "src/tsconfig.spec.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "e2e/tsconfig.e2e.json",
      "exclude": "**/node_modules/**"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "scss",
    "component": {}
  }
}

angular cli文件

scripts.js有效,但custom.js不起作用:(

0 个答案:

没有答案