在sapui5中使用外部js库 [英] Using external js libraries in sapui5

查看:430
本文介绍了在sapui5中使用外部js库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我试图在SAPUI5控制器中包含一个外部.js文件.

So I'm trying to inlcude an external .js file in my SAPUI5 Controller.

    jQuery.sap.includeScript("externalLibrary.min.js", 
    function() {
        //initalizing objects from library
    });

但是,一旦脚本被加载,就应该调用该回调,但是永远不会被调用.它给我的错误信息是:

However, the callback which should be called once the script is loaded, never gets called. The error message it gives me is:

"externalLibrary.min.js:16未捕获的TypeError:无法读取属性 未定义的构造函数"

"externalLibrary.min.js:16 Uncaught TypeError: Cannot read property 'Constructor' of undefined"

还有什么其他方法可以做到这一点?我一直在研究jQuery.sap.registerModulePath()和jQuery.sap.registerResourcePath(),但找不到使用它们的好例子,也找不到关于两者在线区别的解释.

Whats another way I could do this? I was looking into jQuery.sap.registerModulePath() and jQuery.sap.registerResourcePath() but couldn't find a good example of the use of these nor an explaination of the difference between the two online.

非常感谢!

推荐答案

知道了!为了将来参考,它可以像这样从索引html加载文件:

Got it! For future reference, it works to load the files from the index html like so:

 <script src="library.js"></script>

主要问题是我试图包括也包含jQuery的外部依赖项.因此,我不得不从文件中删除它,现在它可以工作了.

The main problem was that I was trying to include external dependencies which also contained jQuery. So, I had to remove that from the file and now it's working.

这篇关于在sapui5中使用外部js库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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