2017-02-09 29 views
-1

我想在Eclipse中使用fiori創建一個完整的應用程序。路由和導航應用Fiori - Eclipse

我有一些路由問題。最初我把我的路由器和路徑放在索引裏,在這種情況下我沒有問題。

之後,Sap建議如何分配功能,並且我創建了其他兩個文件:manifest.json和Component.js。 我哪裏錯了? 在先進的感謝

這是我的索引:

<!DOCTYPE HTML> 
 
<html> 
 
    <head> 
 
\t <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
 
\t <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/> 
 
\t \t <script src="resources/sap-ui-core.js" 
 
\t \t \t \t id="sap-ui-bootstrap" 
 
\t \t \t \t data-sap-ui-libs="sap.m" 
 
\t \t \t \t data-sap-ui-theme="sap_bluecrystal" 
 
\t \t \t \t data-sap-ui-compatVersion="edge" 
 
\t \t \t \t data-sap-ui-preload="async" 
 
\t \t \t \t data-sap-ui-resourceroots='{ 
 
\t \t \t \t "Routing": "./" }'> 
 
\t \t </script> 
 
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme --> 
 

 

 
\t \t <script> 
 
\t \t   sap.ui.getCore().attachInit(function(){ 
 
\t \t   \t new sap.m.Shell({ 
 
\t \t   \t \t app: new sap.ui.core.ComponentContainer({ 
 
\t \t   \t \t \t height : "100%", 
 
\t \t   \t \t \t name : "Routing" 
 
\t \t   \t }) 
 
\t \t   }).placeAt("content"); 
 
\t \t   }); \t \t   \t \t \t 
 
\t \t </script> 
 
\t </head> 
 
\t <body class="sapUiBody" role="application"> 
 
\t \t <div id="content"></div> 
 
\t </body> 
 
</html>

這是組件:

sap.ui.define([ 
 
\t "sap/ui/core/UIComponent" 
 
], function (UIComponent) { 
 
\t "use strict"; 
 
\t return UIComponent.extend("Routing.Component", { 
 
\t \t metadata: { 
 
\t \t \t manifest: "json" 
 
\t \t }, 
 
\t \t init: function() { 
 
\t \t \t // call the init function of the parent 
 
\t \t \t UIComponent.prototype.init.apply(this, arguments); 
 
\t \t \t // router.register("appRouter"); 
 
\t \t \t // create the views based on the url/hash 
 
\t \t \t this.getRouter().initialize(); 
 
\t \t } 
 
\t }); 
 
});

這是清單:

{ 
 
\t "_version": "1.1.0", 
 
\t "sap.app": { 
 
\t \t "_version": "1.1.0", 
 
\t \t "id": "Routing", 
 
\t \t "type": "application", 
 
\t \t "i18n": "i18n/i18n.properties", 
 
\t \t "title": "{{routingnavigation2}}", 
 
\t \t "description": "{{appDescription}}", 
 
\t \t "applicationVersion": { 
 
\t \t \t "version": "1.0.0" 
 
\t \t } 
 
\t }, 
 
\t "sap.ui": { 
 
\t \t "_version": "1.1.0", 
 
\t \t "technology": "UI5", 
 
\t \t "deviceTypes": { 
 
\t \t \t "desktop": true, 
 
\t \t \t "tablet": true, 
 
\t \t \t "phone": true 
 
\t \t }, 
 
\t \t "supportedThemes": ["sap_bluecrystal"] 
 
    \t }, 
 
\t "sap.ui5": { 
 
\t \t "_version": "1.1.0", 
 
\t \t "rootView": { 
 
\t \t  "viewName": "Routing.view.main", 
 
\t \t  "type": "XML" 
 
\t \t  # "id": "home" 
 
\t \t  }, 
 
\t \t "dependencies": { 
 
\t \t \t "minUI5Version": "1.30", 
 
\t \t \t "libs": { 
 
\t \t \t \t "sap.ui.core": {}, 
 
\t \t \t \t "sap.m": {}, 
 
\t \t \t \t "sap.ui.layout": {}, 
 
\t \t \t \t "sap.ushell": {} 
 
\t \t \t } 
 
\t \t }, 
 
\t \t "contentDensities": { 
 
\t \t \t "compact": true, 
 
\t \t \t "cozy": true 
 
\t \t }, 
 
\t \t "models": { 
 
\t \t  "i18n": { 
 
\t \t \t "type": "sap.ui.model.resource.ResourceModel", 
 
\t \t \t "settings": { 
 
\t \t \t \t "bundleName": "Routing.i18n.i18n.properties" 
 
\t \t \t \t } 
 
\t \t \t } 
 
\t \t }, 
 
\t \t "routing": { 
 
\t \t \t "config": { 
 
\t \t \t  "RouterClass": "sap.m.routing.Router", 
 
\t \t \t  "viewType": "XML", 
 
\t \t \t  "viewPath": "Routing.routingnavigation.view", 
 
\t \t \t \t "controlId": "app", 
 
\t \t \t \t "targetAggregation": "pages" 
 
\t \t \t }, 
 
\t \t \t "routes": [{ 
 
\t \t \t \t "pattern": "", 
 
\t \t \t \t "name": "view1", 
 
\t \t \t \t "viewName" : "view.view1", 
 
\t \t \t \t "targetAggregation": "pages" 
 
\t \t \t }, 
 
\t \t \t { 
 
\t \t \t "pattern": "view2", 
 
\t \t \t \t "name": "view2", 
 
\t \t \t \t "viewName" : "view.view2", 
 
\t \t \t \t "targetAggregation": "pages" 
 
\t \t \t }] 
 
\t \t }, 
 
\t } 
 
}

這是錯誤的圖像:

error 'initialize'

這是結構的圖像: enter image description here

+0

1) 在錯誤消息它說,它無法找到manifest.json的: 「無法加載組件從‘路由/ manifest.json的’...檢查清單‘未找到文件’......「 如何Eclipse中的文件結構看起來像? manifest.json位於何處? 2) 也許下面的鏈接幫助:第4步:[XML Views](https://sapui5.hana.ondemand.com/#docs/guide/1409791afe4747319a3b23a1e2fc7064.html) –

+0

嗨,謝謝你的回覆。清單錯誤,是我的錯,試圖找到我犯另一個錯誤。 我解決不了的錯誤是 遺漏的類型錯誤:無法讀取屬性「初始化」的不確定 – Mavhart

+0

在你的manifest.json它說:「RoutingClass」:「sap.m.routing.Routing」, 會發生什麼,如果你試試: 「routerClass」:「sap.m.routing.Router」,? –

回答

0

有是三個與t相關的語法錯誤Ø清單文件:

  • 錯位#和下rootView設置"type": "XML"之後缺少,
    "rootView": { 
        "viewName": "Routing.view.main", 
        "type": "XML" 
    # "id": "home" 
    }, 
    
  • 區分大小寫:"RouterClass"應該與你的"config"設置"routerClass"所取代。
  • 根據您的屏幕截圖,您的描述符的文件名是M anifest.json。它應該是m anifest.json。否則,component won't find the file

讓我們知道它是否工作。否則,如果您正在使用Web IDE,請單擊右下角的⚠️️標誌以查看是否有更多語法錯誤(編輯:Eclipse,使用正確的插件,也應該爲json文件提供語法高亮顯示)。

SAP Web IDE error panel


PS:這裏是基本的導航的最小例子進行比較:https://embed.plnkr.co/wp6yes/。要詳細瞭解如何在UI5中實現導航的最佳做法,請查看其tutorial

+0

嗨boghyon,感謝您的relply。我已經看到了錯誤,我星期五糾正了它們,但它不起作用。 (我剛剛爲json安裝了一個插件,感謝您的建議!!) – Mavhart

+0

嗨。控制檯是否仍然說'不能讀取屬性'undefined'的初始化?或者你有不同的錯誤信息?我剛剛添加了一個展示基本導航的Plunker頁面。如果沒有任何工作..;) – boghyon

+0

感謝boghyon,我創建了一個快速項目跟着你的例子,但我發現同樣的錯誤。我不知道爲什麼。 依賴eclipse可能會出現一些問題嗎? 也許我必須做一些不同的事情? 我知道這不是一個正確的說法,但我不知道更多的想法。 P.S.我遵循了你建議的鏈接(除了模擬服務器) – Mavhart