【问题标题】:resource view/View1.view.xml could not be loaded from resources/view/View1.view.xml. in WebIDE资源视图/View1.view.xml 无法从资源/视图/View1.view.xml 加载。在 WebIDE 中
【发布时间】:2017-03-13 21:36:38
【问题描述】:

当我尝试从文件夹“视图”加载视图时,出现错误“资源视图/View1.view.xml 无法从资源/视图/View1.view.xml 加载”。 WebIDE中的文件夹结构如下图。

index.html

<!DOCTYPE HTML>
<html>
<head>
<script id="sap-ui-bootstrap"
        src="resources/sap-ui-core.js"
        data-sap-ui-libs="sap.m"
        data-sap-ui-theme="sap_bluecrystal" >
</script>
    <script>
        sap.ui.localResources("webapp");
        var app = new sap.m.App("idApp");
        var view1 = sap.ui.view({id:"idView1", 
        viewName:"view.View1",type:sap.ui.core.mvc.ViewType.XML});
    </script>
 </head>
 <body class="sapUiBody" role="application">
    <div id="content" ></div>
 </body>
 </html>

View1.xml

 <mvc:View 
            xmlns="sap.m" 
            xmlns:mvc="sap.ui.core.mvc">
<Text id="idbtn" text="Text from" />

</mvc:View>

View1.controller

sap.ui.define([
    "sap/ui/core/mvc/Controller"
], function(Controller) {
    "use strict";

    return Controller.extend("View1");

});

neo-app.json

{
  "routes": [
    {
      "path": "/webapp/resources",
      "target": {
        "type": "service",
        "name": "sapui5",
        "entryPath": "/resources"
      },
      "description": "SAPUI5 Resources"
    }
    ]
}

浏览器错误

我尝试了几种方法,但找不到指向 View1.xml 的方法

提前致谢, 斯里尼。

【问题讨论】:

    标签: resources sapui5 web-ide


    【解决方案1】:

    请在脚本标签内使用data-sap-ui-resourceroots'{"webapp": "./" }'index.html 中的视图名称应为webapp.view.View1

    【讨论】:

      【解决方案2】:

      sap.ui.localResources("webapp");webapp 命名空间注册 webapp 文件夹。您也可以在控制台中看到这一点。

      所以应该是viewName: "webapp.view.View1"

      还请注意,您的控制器随后称为 webapp.controller.View1

      return Controller.extend("webapp.controller.View1", {
      

      ...

      【讨论】:

      • @schnoadel,我根据您的建议更改了视图名称规范。但仍然收到错误。我可以在控制台中看到文件夹路径的差异,但仍然无法正常工作。更改后,控制台中的路径反映为 webapp/webapp/view/View1.view.xml
      猜你喜欢
      • 2014-08-17
      • 2012-07-26
      • 1970-01-01
      • 2019-04-30
      • 2015-08-08
      • 1970-01-01
      • 2012-11-15
      • 1970-01-01
      • 2017-04-05
      相关资源
      最近更新 更多