未定义jQuery,电子

问题描述 投票:0回答:1

我正在电子应用程序中使用Microsoft adal进行身份验证。使用jQuery在我的应用程序中无处显示,但是当我尝试注销时,[我在应用程序控制台中收到此错误]

enter image description here

const redirectTo = `https://login.microsoftonline.com/${config.Adal.TenantID}/oauth2/v2.0/logout?post_logout_redirect_uri=${authContext.config.postLogoutRedirectUri}`;

const logout = () => {
    authContext.logOut();
    redirect(redirectTo, '/');    
};

authContext文件

export const adalConfig = {
  clientId: config.Adal.ClientID,
  tenant: config.Adal.TenantID,
  cacheLocation: 'localStorage',
  redirectUri: config.Adal.RedirectURI,
  postLogoutRedirectUri: loginUrl
};

export const authContext = new AuthenticationContext(adalConfig);

[在我们注销您时,应用程序停留在“挂起”。

javascript node.js reactjs electron adal
1个回答
0
投票

如果您尝试用Uncaught ReferenceError: jQuery is not defined搜索关键字Electron来解决问题,您将获得许多解决方案来解决。

常用解决方案如下。

  1. 如果您通过<script src="http://code.jquery.com/jquery-1.11.1.js"></script>加载jQuery库,则在通过<script>window.$ = window.jQuery = require('jquery')</script>安装jQuery时,请在Electron中使用npm install --save jquery代替它。

  2. nodeIntegration: true更改为nodeIntegration: false以在BrowserWindow实例中禁用Node.js。

  3. 将[jQuery的开始内容替换为!function(a,b){b(a)}中的选举中的静态资源资产。

    // The beginning content need to be replaced
    !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}
    
© www.soinside.com 2019 - 2024. All rights reserved.