• Step 15: Nested Views


    Step 15: Nested Views

    嵌套view
    当画面的控件变多后,最好不要只用一个view,分成多个view比较利于后面的维护和重用,所以就要使用的嵌套view

    webapp/view/App.view.xml

    <mvc:View
    	controllerName="sap.ui.demo.walkthrough.controller.App"
    	xmlns="sap.m"
    	xmlns:mvc="sap.ui.core.mvc"
    	displayBlock="true">
    	<Shell>
    		<App class="myAppDemoWT">
    			<pages>
    				<Page title="{i18n>homePageTitle}">
    					<content>
    						<mvc:XMLView viewName="sap.ui.demo.walkthrough.view.HelloPanel"/>
    					</content>
    				</Page>
    			</pages>
    		</App>
    	</Shell>
    </mvc:View>
    

    把Panel里的内容,封装成一个view

    webapp/view/HelloPanel.view.xml (New)

    <mvc:View
       controllerName="sap.ui.demo.walkthrough.controller.HelloPanel"
       xmlns="sap.m"
       xmlns:mvc="sap.ui.core.mvc">
       <Panel
          headerText="{i18n>helloPanelTitle}"
          class="sapUiResponsiveMargin"
          width="auto" >
          <content>
             <Button
                text="{i18n>showHelloButtonText}"
                press=".onShowHello"
                class="myCustomButton"/>
             <Input
                value="{/recipient/name}"
                valueLiveUpdate="true"
                width="60%"/>
             <FormattedText
                htmlText="Hello {/recipient/name}"
                class="sapUiSmallMargin sapThemeHighlight-asColor myCustomText"/>
          </content>
       </Panel>
    </mvc:View>
    

    把原来App.view.xml里panel部分的内容移动到这里。并指定一个新的controller。

    webapp/controller/HelloPanel.controller.js (New)

    sap.ui.define([
       "sap/ui/core/mvc/Controller",
       "sap/m/MessageToast"
    ], function (Controller, MessageToast) {
       "use strict";
       return Controller.extend("sap.ui.demo.walkthrough.controller.HelloPanel", {
          onShowHello : function () {
             // read msg from i18n model
             var oBundle = this.getView().getModel("i18n").getResourceBundle();
             var sRecipient = this.getView().getModel().getProperty("/recipient/name");
             var sMsg = oBundle.getText("helloMsg", [sRecipient]);
             // show message
             MessageToast.show(sMsg);
          }
       });
    });
    

    把原来在App.controller.js里的按钮点击事件的代码移动到这里。

    webapp/controller/App.controller.js

    sap.ui.define([
       "sap/ui/core/mvc/Controller"
    ], function (Controller) {
       "use strict";
       return Controller.extend("sap.ui.demo.walkthrough.controller.App", {
       });
    });
    

    把原来在App.controller.js里的按钮点击事件的代码删除掉。

    vx:xiaoshitou5854

  • 相关阅读:
    Oracle 安装安全补丁过程中出现的问题
    Oracle 设置日志模式
    Oracle 设置archivelog错误解决方案
    sum() over() 函数的使用
    C盘清理,移动node 依赖和缓存文件
    ol设置最佳可视范围和限制缩放
    flex弹性布局模式下文字超出显示省略号
    查看svn本地账户和密码
    flutter apk启动闪退问题
    More than one file was found with OS independent path 'lib/armeabi-v7a/libflutter.so'
  • 原文地址:https://www.cnblogs.com/xiaoshiwang/p/15188195.html
Copyright © 2020-2023  润新知