liferay 7 - Mismatched anonymous define()

筅森魡賤 提交于 2019-12-11 03:39:31

问题


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 ()...

and then the library isn't loaded.

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

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

I don't have any idea to make it work


回答1:


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'

To:

false && typeof define == 'function'

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



来源:https://stackoverflow.com/questions/43064052/liferay-7-mismatched-anonymous-define

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!