天天看點

關于 SAP UI5 裡包含的 jQuery 版本

How to find the jQuery version used by SAPUI5

sap-ui-core.js 是 bootstrap 部分的一部分,如下所示。 它包含一個 jQuery 檔案的副本。 正在使用的 jQuery 版本可以通過指令 $.fn.jQuery 找到。

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

        <script src="resources/sap-ui-core.js"
                id="sap-ui-bootstrap"
                data-sap-ui-libs="sap.m"
                data-sap-ui-theme="sap_bluecrystal">
        </script>

        <script>
            
        </script>

    </head>
    <body class="sapUiBody" role="application">
        <div id="content"></div>
    </body>
</html>
      
關于 SAP UI5 裡包含的 jQuery 版本

Add a custom version of jQuery

在應用程式的 WebContent 中建立一個新檔案夾并為其指定任何名稱。 我們稱之為jquery。 下載下傳您想要的 jQuery 版本并将其放在此檔案夾中。

關于 SAP UI5 裡包含的 jQuery 版本

Modify index.html

打開 index.html 檔案并使用以下代碼更新它。 添加了新 jQuery 檔案的路徑以及 jquery-ui-position.js 的路徑。 SAPUI5 使用 jQuery UI Position 1.10.4 來定位彈出視窗、工具提示等。 jQuery UI 版本 1.10.4 包含與 jQuery UI 版本 1.8.23 不相容的更改。 jQuery.ui.position 中的一個主要不相容更改,其中 offset 屬性已被删除。 SAPUI5 運作時采用了此更改,例如在 Popup 中,但應用程式可能也需要采用其邏輯。

要跳過 SAPUI5 運作時使用 jQuery,resources / sap-ui-core-noJQuery.js 檔案包含在 bootstrap 部分。

新的 index.html:

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

        <!-- include some jQuery version -->
        <script src="jquery/jquery-2.1.0.js" ></script>

        <!-- SAPUI5 uses jQuery UI Position 1.10.4 for positioning popups, tooltips, etc. -->
        <script src="resources/sap/ui/thirdparty/jqueryui/jquery-ui-position.js" ></script>

        <!--
        <script src="resources/sap-ui-core.js"
                id="sap-ui-bootstrap"
                data-sap-ui-libs="sap.m"
                data-sap-ui-theme="sap_bluecrystal">
        </script>
        -->
        
        <script src="resources/sap-ui-core-nojQuery.js"
                id="sap-ui-bootstrap"
                data-sap-ui-libs="sap.m"
                data-sap-ui-theme="sap_bluecrystal">
        </script>       

        <script>
                sap.ui.localResources("sapui5.jqverchange.demo");
                var app = new sap.m.App({initialPage:"idmain1"});
                var page = sap.ui.view({id:"idmain1", viewName:"sapui5.jqverchange.demo.main", type:sap.ui.core.mvc.ViewType.XML});
                app.addPage(page);
                app.placeAt("content");
        </script>

    </head>
    <body class="sapUiBody" role="application">
        <div id="content"></div>
    </body>
</html>
      

最後的效果,能看到自定義版本的 jQuery 已經生效了:

關于 SAP UI5 裡包含的 jQuery 版本

繼續閱讀