liferay 7-不匹配的匿名define() [英] liferay 7 - Mismatched anonymous define()

查看:93
本文介绍了liferay 7-不匹配的匿名define()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的liferay 7 portlet中包含sockjs(v1.1.2),但是我收到此警告:

I'm trying to include sockjs (v1.1.2) in my liferay 7 portlet, but I'm receiving this warning:

Mismatched anonymous define() module: function ()...

然后没有加载库.

我将.js文件直接包含在我的liferay-portlet.xml中,如下所示:

I directly included the .js file in my liferay-portlet.xml like this:

<header-portlet-javascript>/common/js/sockjs.js</header-portlet-javascript>

我不知道该怎么做

推荐答案

看起来您遇到了由 LPS-68298 .如果您使用的是Liferay 7.0 DXP SP2 +或Liferay 7.0 CE GA4 +,则只需打开管理侧边栏,然后选择控制面板> 配置> 系统设置 > Foundation > JavaScript Loader >取消选中公开全局.如果您未使用上述Liferay版本之一,则需要遵循此答案,并在加载脚本之前禁用AMD加载器,然后重新启用AMD加载器.另外,您可以通过手动编辑JS文件来解决此问题.更改 /common/js/sockjs.js 中的任何文本,例如:

Looks like you are running into an issue that's been fixed by LPS-68298. If you are using Liferay 7.0 DXP SP2+ or Liferay 7.0 CE GA4+ you can simply open the administration sidebar and select Control Panel > Configuration > System Settings > Foundation > JavaScript Loader > Uncheck Expose Global. If you aren't using one of the above Liferay versions, you need to follow the advice of this answer and disable the AMD loader before loading your script, then re-enable the AMD loader. Alternatively, you can fix this by manually editing your JS file. Change any text in /common/js/sockjs.js like:

typeof define == 'function'

收件人:

false && typeof define == 'function'

这将阻止文件由Liferay的AMD加载器加载.

This will stop the file from being loaded by Liferay's AMD loader.

这篇关于liferay 7-不匹配的匿名define()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆