【问题标题】:SAP UI5 How to append HTML in xml ViewSAP UI5 如何在 xml 视图中附加 HTML
【发布时间】:2019-02-22 09:11:03
【问题描述】:

我想在 xml 视图中使用 vis.js 库。

这是 XML 视图:

<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns:m="sap.m" controllerName="com.asas.mes.controller.timeline" xmlns="http://www.w3.org/1999/xhtml">
<m:Page>
    <div id="visualization"></div>
</m:Page>

这是控制器:

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

    return Controller.extend("com.asas.mes.controller.timeline", {

        onInit: function() {

            jQuery.sap.registerModulePath("modulePath", "/XMII/CM/mes/vis-4.21.0");
            jQuery.sap.require("modulePath.vismin");
            var test = this.getView().byId("visualization");

             var items = new vis.DataSet([
             {id: 1, content: 'item 1', start: '2014-04-20'},
             {id: 2, content: 'item 2', start: '2014-04-14'},
             {id: 3, content: 'item 3', start: '2014-04-18'},
             {id: 4, content: 'item 4', start: '2014-04-16', end: '2014-04-19'},
             {id: 5, content: 'item 5', start: '2014-04-25'},
             {id: 6, content: 'item 6', start: '2014-04-27', type: 'point'}
  ]);

  // Configuration for the Timeline
  var options = {};

  // Create a Timeline
  var timeline = new vis.Timeline(container, items, options);

        }

    });
});

但我收到此错误:

error ss:

错误代码:未捕获类型错误:t.appendChild 不是函数

【问题讨论】:

标签: sapui5 vis.js vis.js-timeline


【解决方案1】:

试试这个。

记得包含命名空间core

<mvc:View
...
xmlns:core="sap.ui.core"
...>

希望对你有帮助。

查看

    <Page title="{i18n>title}">
        <content>
            <core:HTML id="idHTMLContent"/>
        </content>
    </Page>

控制器

    onInit: function(){
        this.byId("idHTMLContent").setContent("<div id='visualization'></div>");
    }

Style.css

#visualization {
    background:green;
    width: 100%;
    height:200px;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2014-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多