我在我的 Electron 应用程序中使用 microsoft adal 进行身份验证。在我的应用程序中无处使用 jQuery,但是当我尝试注销时,[我在应用程序控制台中收到此错误]
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, '/');
};
身份验证上下文文件
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);
该应用程序卡在“我们注销您时稍等片刻”。
最佳答案
如果您尝试搜索关键字 Uncaught ReferenceError: jQuery is not defined
与 Electron
对于您的问题,您将获得许多解决方案来解决它。
常用的解决方法如下。
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
这样的 jQuery 库, 请使用 <script>window.$ = window.jQuery = require('jquery')</script>
当您通过 npm install --save jquery
安装 jQuery 时,而不是在 Electron 中. nodeIntegration: true
至 nodeIntegration: false
在 BrowserWindow
中禁用 Node.js实例。 !function(a,b){b(a)}
替换jquery开头的内容作为Election中的静态资源 Assets .// 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)}
关于javascript - jQuery 未定义,Electron,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59634908/