将 SRC 从 Index.html 移动到组件 ui5 [英] Moving SRC from Index.html to Component ui5

查看:26
本文介绍了将 SRC 从 Index.html 移动到组件 ui5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的索引中有以下行,我的应用程序运行良好.

So I have the following line in my Index and my app works perfectly.

<script src="/sap/bc/ui5_ui5/sap/project/util/moment.js"> </script>
<script src="/sap/bc/ui5_ui5/sap/project/util/moment-timezone-with-data-2010-2020.js"> </script>

但现在我的应用程序被称为组件,我需要将其移动到组件部分.但我不确定如何做到这一点.我尝试了一些没有运气的东西.

But now my application is being called as a Component I need to move this to the Component section. But I'm unsure how to do this. I've tried a few things with no luck.

如果我删除这行代码,当我的应用程序作为独立运行时,我会在我的应用程序中遇到相同的错误,就像我通过组件调用它时所做的那样,所以我知道这是缺少的代码行.任何帮助,将不胜感激.

If I remove this line of code I get the same error in my application when its ran as a standalone as I do when I call it via the component, so I know this is the line of code that is missing. Any help would be appreciated.

推荐答案

更好地使用 manifest.json 文件中的资源"节点,如下所示:

Use better the "resources" node in your manifest.json files like this:

    "resources": {
        "js": [ {
            "uri": "URI/to/JS/file.js",
            "name": "filename.js",
            "version": "1.1.1"
        }]
    }

或者在 Component.js 文件中的 init 事件中使用 JQuery.sap.require()

Or use JQuery.sap.require() in your init event in the Component.js file

  jQuery.sap.require('namespace.folder.fileName')

您应该阅读两篇好文章:

There are two good posts you should read:

  1. https://blogs.sap.com/2017/04/30/how-to-include-third-party-libraries-modules-in-sapui5/
  2. https://blogs.sap.com/2016/10/29/sapui5-application-startup-performance-best-practices/

这篇关于将 SRC 从 Index.html 移动到组件 ui5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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