【发布时间】:2021-02-21 11:33:42
【问题描述】:
我正在尝试在 XPage 中使用 jsSHA JavaScript 库。
var shaObj = new jsSHA('SHA-1','HEX');给出运行时错误:[ReferenceError] 'jsSHA' not found
<xp:this.resources>
<!-- temporary redefine define.amd object (Dojo AMD loader) -->
<xp:script clientSide="true" type="text/javascript">
<xp:this.contents><![CDATA[${javascript:"if (typeof define === 'function' && define.amd) {if(define.amd.vendor =='dojotoolkit.org'){define._amd = define.amd;delete define.amd;}}";}]]></xp:this.contents>
</xp:script>
<xp:script src="sha.js" clientSide="true"></xp:script>
<xp:script src="https://code.jquery.com/jquery-3.5.1.min.js" clientSide="true"></xp:script>
<!-- restore define.amd object (Dojo AMD loader) -->
<xp:script clientSide="true">
<xp:this.contents><![CDATA[${javascript:"if (typeof define === 'function' && define._amd) {define.amd = define._amd; delete define._amd;}"}]]></xp:this.contents>
</xp:script>
</xp:this.resources>
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:var shaObj = new jsSHA('SHA-1','HEX');
return shaObj ;
}]]></xp:this.value></xp:text>
当我删除我的计算字段时,我可以看到 sha.js 和 jquery 已加载
我从https://caligatio.github.io/jsSHA/sha.js得到了sha文件
【问题讨论】:
标签: javascript jquery xpages xpages-ssjs