我有一个 XPage,它只使用 2 个 js 导入 - 其中一个是 JQuery,另一个依赖于 JQuery,它用于俄罗斯联邦的智能公司搜索。我遇到的问题是,当我尝试导入第二个库时,整个页面变得无响应(例如无法单击任何按钮)。
这就是我的意思:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:script
src="https://code.jquery.com/jquery-3.3.1.js"
clientSide="true">
</xp:script>
<!-- the problematic library -->
<xp:script src="https://cdn.jsdelivr.net/npm/suggestions-jquery/dist/js/jquery.suggestions.js"
clientSide="true">
</xp:script>
<xp:styleSheet
href="https://cdn.jsdelivr.net/npm/suggestions-jquery/dist/css/suggestions.min.css">
</xp:styleSheet>
</xp:this.resources>
<xp:div>
</xp:div>
<xp:button id="Unresponsive button">
Here's the unresponsive button
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[alert('we'll never be able to see this')]]></xp:this.script>
</xp:eventHandler></xp:button>
</xp:view>
因此,当我导入第二个库时,页面变得无响应(CSJS 和 SSJS 都不执行)。我不知道为什么会发生这种情况。当我编写相同的代码,但只是作为一个普通的 HTML 页面时,我不会遇到这个问题。这只是 XPage 的一个功能吗?也许,我可以使用一些额外的导入参数来避免这个问题?提前致谢。
最佳答案
jquery.suggestions.js 库使用 AMD 加载器,与 XPage 中的 Dojo 冲突。请参阅this answer类似的问题。
关于javascript - 使用 jquery 导入某些库会卡住整个 xpage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55529140/