对话框不是构造函数 ui5

尤斯拉·萨奥迪

在 sapui5 中使用重用对话框时出现错误:

对话框不是构造函数

我想创建一个对话框片段。dialog.js 包含所有函数,然后在 component.js 中将其设为全局

sap.ui.define([
    "sap/ui/base/Object"
], function (Object) {
    "use strict";

    return Object.extend("tmp.Zprojetyousra.controller.Dialog", {
        constructor : function (oView) {
            this._oView = oView;    
        },
        open : function () {
            var oView = this._oView;
            var oDialog = oView.byId("dialog");
            // create dialog lazily
            if (!oDialog) {
                var oFragmentController = {
                    onCloseDialog : function () {
                        oDialog.close();
                    }
                };
                // create dialog via fragment factory
                oDialog = sap.ui.xmlfragment(oView.getId(), "tmp.Zprojetyousra.view.Dialog", oFragmentController);
                // connect dialog to the root view of this component (models, lifecycle)
                oView.addDependent(oDialog);
            }
            oDialog.open();
        }
    });
});

HTML:

<core:FragmentDefinition
    xmlns="sap.m"
    xmlns:core="sap.ui.core">
    <Dialog
        id="dialog"
        title="Hello dialogs}">
        <content>
            <core:Icon
                src="sap-icon://hello-world"
                size="8rem"
                class="sapUiMediumMargin"/>
        </content>
        <beginButton>
            <Button
                text="{i18n>dialogCloseButtonText}"
                press="onCloseDialog"/>
        </beginButton>
    </Dialog>
</core:FragmentDefinition>

JS:

sap.ui.define([
    "sap/ui/core/UIComponent",
/*    "tmp/Zprojetyoussra/model/models",  peut influencer sur le code                         */
    "sap/ui/model/json/JSONModel",

    "tmp/Zprojetyoussra/controller/Dialog"    ,
    "sap/ui/Device"
     /// device toujours doit etre a la fin des dependecies
], function (UIComponent, JSONModel, Device, Dialog) {
    "use strict";

    return UIComponent.extend("tmp.Zprojetyoussra.Component", {
        metadata: {
    //        rootView: "tmp.Zprojetyoussra.view.tesstview"
            manifest: "json"
        },
        init: function () {
            // call the base component's init function
            UIComponent.prototype.init.apply(this, arguments);

            // set data model
            var oData = {
                recipient : {
                    name : "World"
                }
            };
            // without this.getview
            var oModel = new sap.ui.model.json.JSONModel(oData);
            this.setModel(oModel);
            // set i18n model
            var i18nModel = new sap.ui.model.resource.ResourceModel({
                bundleName : "tmp.Zprojetyoussra.i18n.i18n"
            });
            this.setModel(i18nModel, "i18n");

            /* eslint-disable no-alert */
            // debug code to show an alert for missing destination or CORS issues in the tutorial (see step 26 for details)
            this.getModel("invoice").attachEventOnce("metadataFailed", function(oEvent) {
                alert("Request to the OData remote service failed.\nRead the Walkthrough Tutorial Step 26 to understand why you don't see any data here.");
            });
            // set device model
            var oDeviceModel = new JSONModel(Device);
            oDeviceModel.setDefaultBindingMode("OneWay");
            this.setModel(oDeviceModel, "device");
            this._dialog= new Dialog();
            // create the views based on the url/hash
            this.getRouter().initialize();
        }   
    });
});

错误:

图片

瓦塞克

您在控制器定义部分的导入顺序错误。在数组中,您有:

UIComponent, JSONModel, Dialog, Device

但在下面的函数定义中,你有:

UIComponent, JSONModel, Device, Dialog

因此 Dialog 变量包含没有控制器的 Device 命名空间。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在外部单击时关闭UI5对话框

来自分类Dev

如何通过UI5中的XML模板覆盖/禁用“对话框”的“ escapeHandler”?

来自分类Dev

由于“ TypeError:...不是构造函数”,无法实例化UI5类

来自分类Dev

离开视图时,不会在UI5中销毁/重置基于片段的对话框

来自分类Dev

jQuery UI对话框打开多个对话框而不是一个

来自分类Dev

对话框不是MVC 5中的功能

来自分类Dev

调用函数(如果打开了任何ui对话框)

来自分类Dev

从对话框按钮jQuery UI调用函数

来自分类Dev

动态jQuery UI对话框回调函数问题

来自分类Dev

sapui5:-下拉框中的ui5上未显示文本

来自分类Dev

jQuery对话框对话框不是函数

来自分类Dev

UI5:从自定义控件调用视图中的函数

来自分类Dev

带对话框的Javascript构造函数

来自分类Dev

对话框不是函数-React

来自分类Dev

对话框不是函数-React

来自分类Dev

jQuery UI-未定义不是对话框上的函数

来自分类Dev

jQuery UI-未定义不是对话框上的函数

来自分类Dev

jQuery UI Button函数在弹出对话框打开时执行

来自分类Dev

jQuery UI Button函数在弹出对话框打开时执行

来自分类Dev

UI对话框多次打开

来自分类Dev

jQuery UI对话框的关闭效果

来自分类Dev

现代UI对话框结果问题

来自分类Dev

jQuery UI对话框顶部间距

来自分类Dev

可扩展的jQuery UI对话框

来自分类Dev

UI对话框按钮隐藏控件

来自分类Dev

jQuery UI对话框:从内部关闭

来自分类Dev

UI对话框多次打开

来自分类Dev

jQuery UI对话框并关闭

来自分类Dev

从jQuery UI对话框回调