SAPUI5 Structure,Component.js,manifest.json和Component-preload

时间:2018-02-16 18:38:04

标签: sapui5

我收到以下错误:

未捕获错误:无法从resources / Main.view.xml加载资源Main.view.xml。检查“找不到文件”或解析错误。

我正在使用Eclipse。我创建了我的项目,所以我重新构建了这样的文件夹:

enter image description here

然后,我在视图和控制器上改变我的路线

Main.view.xml

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
		controllerName="Deplo.Test.Controller.Main" xmlns:html="http://www.w3.org/1999/xhtml">
	<Page title="Title">
		<content>
			<Text text="Prueba" />
			<Button text="Push" />
		</content>
	</Page>
</core:View>

Main.controller.js

sap.ui.controller("Deplo.Test.Controller.Main", { });

我在哪里可以下载o加载我的component.js,manifest.json和Component-preload.js ????是因为这些文件夹不是自动创建的,为什么使用组件预载?如果有人有一些教程博客,请告诉我。我一直在使用sap web ide但是在这里我们没有云连接器所以web ide不适合我:C

1 个答案:

答案 0 :(得分:0)

您必须定义自定义resourceroot。您可以通过添加data-sap-ui-resourceroots属性来执行此操作:

<script src="resources/sap-ui-core.js"
    id="sap-ui-bootstrap"
    data-sap-ui-libs="sap.m"
    data-sap-ui-theme="sap_bluecrystal"
    data-sap-ui-resourceroots='{ "your.namespace.app": "./" }'>
</script>

现在,命名空间your.namespace.app已配置为根文件夹结构./

在此之后,您需要使用此命名空间为每个控制器和视图添加前缀。

  1. 在您的观看中,更改controllerName

    来自controllerName="Controller.Main"

    controllerName="your.namespace.app.controller.Main"

  2. 在控制器中更改扩展名:

    来自BaseController.extend("Controller.Main", {})

    BaseController.extend("your.namespace.app.controller.Dashboard", {})

  3.   

    顺便说一下,UI5 Walkthrough是一个很好的起点!