【问题标题】:electron-forge: add jquery电子锻造:添加 jquery
【发布时间】:2018-05-15 15:32:12
【问题描述】:

在我使用电子锻造创建的电子角度应用程序中,我正在尝试导入 jquery。

我做了以下步骤:

  1. 已安装 jquery

    yarn add jquery --save
    
  2. 已安装的类型

    yarn add @types/jquery --save
    
  3. 导入到 app.module

    import * as $ from 'jquery';
    

当我启动应用程序时,我得到了

index.js:21 Uncaught ReferenceError: $ is not defined
at index.js:21

【问题讨论】:

    标签: jquery angular electron


    【解决方案1】:

    我不能保证,但请尝试将您的 .angular-cli.json 添加到脚本数组中 "scripts": [ "../node_modules/jquery/dist/jquery.js" ],

    并在您的组件中在导入其他模型后添加此字符串 declare var $: any;

    在简单的 angular-cli 应用程序中它工作正常。对不起我的英语不好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-10
      • 2020-04-08
      • 2019-07-15
      • 2018-12-13
      • 2018-02-06
      • 2020-10-08
      • 2021-06-28
      • 2022-10-17
      相关资源
      最近更新 更多