【问题标题】:how can i add an url link in script part of angular cli project如何在 Angular cli 项目的脚本部分添加 url 链接
【发布时间】:2019-08-12 23:48:45
【问题描述】:
"scripts": [
      "@import http://cdnjs.cloudflare.com/ajax/libs/jquery.form/3.32/jquery.form.js",
      "plugins/bootstrap/js/bootstrap.min.js",
      "@import https://code.jquery.com/jquery-git.min.js",
      "./js/script.js"
]

我做对了吗?我需要在那里导入这些链接,但我不知道该怎么做 错误 : Angular Live Development Server 正在监听 localhost:4200,打开浏览器 http://localhost:4200/ ** 92% 额外的资产处理脚本-webpack-plugin×「wdm」: Error: ENOENT: no such file or directory, open 'C:\ms-front-web@import http:\cdnjs.cloudflare.com\ajax\libs\ jquery.form\3.32\jquery.form.js '

【问题讨论】:

    标签: angular


    【解决方案1】:

    似乎不允许在脚本中添加 cdn url,而是应该在 index.html 中包含来自 CDN 的 js/css 文件。

    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.form/3.32/jquery.form.js" />
    

    一些链接供您参考以及如何使用它。 Angular include CDN in component usage https://github.com/angular/angular-cli/issues/2280 https://github.com/angular/angular-cli/issues/6887

    我建议使用 npm 将您的软件包安装为模块并将其包含在您的脚本中。

    示例: npm install bootstrap --save-dev npm install jquery --save-dev 那么

    "scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "../node_modules/bootstrap/dist/js/bootstrap.js"
    ],
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      • 1970-01-01
      相关资源
      最近更新 更多