【问题标题】:how to create global variables in ui5?如何在ui5中创建全局变量?
【发布时间】:2019-03-15 13:37:31
【问题描述】:

我正在尝试使用 UI5 中的窗口将富文本编辑器设为全局变量,但我不断收到错误消息“不允许在窗口对象中定义全局变量/api (sap-no-global-define)”。我的代码看起来像这样

window.oRichTextEditor = new RichTextEditor("myRTE", {
    editorType: sap.ui.richtexteditor.EditorType.TinyMCE4,
    width: "100%",
    height: "600px",
    customToolbar: true,
    showGroupFont: true,
    showGroupLink: true,
    showGroupInsert: true,
    value: data,
    ready: function () {
        this.addButtonGroup("styleselect").addButtonGroup("table");
    }

我想知道为什么这不起作用?有人可以向我解释一下这个错误吗?

【问题讨论】:

标签: sapui5 rich-text-editor


【解决方案1】:

首先,UI5 strictly recommends,不使用全局变量!

如果你真的需要全局变量,你可以使用 ObjectPath.set()

sap.ui.require(["sap/base/util/ObjectPath"], function (ObjectPath) {
      ObjectPath.set(["oRichTextEditor"], "I_Know_What_I_Am Doing!");
});

【讨论】:

    猜你喜欢
    • 2014-11-29
    • 2011-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多