拉力赛 SDK 2.0 Ext.DomHelper

Rally SDK 2.0 Ext.DomHelper

我正在使用 Rally SDK 2.0 来提交报告,我需要在其中进行一些自定义 html。

我查看了文档并找到了 DomHelper (https://help.rallydev.com/apps/2.1/doc/#!/api/Ext.DomHelper),它看起来应该可以解决问题,但是当我尝试 运行 示例代码时出现以下错误。 对我在这里做错了什么有什么想法吗?

sdk-debug.js:147611

Error: success callback for Deferred transformed result of Deferred transformed result of Deferred threw: TypeError: Cannot read property 'insertAdjacentHTML' of null at constructor.insertHtml (sdk-debug.js:14995) at constructor.doInsert (sdk-debug.js:14957) at constructor.append (sdk-debug.js:12905) at constructor.launch (App.js?_dc=0.3312545995932721:11) at constructor._applyDefaultSettingsAndLaunch (sdk-debug.js:155148) at constructor.loadSettingsAndLaunch (sdk-debug.js:155054) at constructor.initComponent (sdk-debug.js:155032) at constructor (sdk-debug.js:30211) at constructor.callParent (sdk-debug.js:4469) at constructor [as _componentConstructor] (sdk-debug.js:34291)

Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
    //Write app code here
    var dh = Ext.DomHelper; // create shorthand alias
    // create the node
    var list = dh.append('my-div', {tag: 'ul', cls: 'my-list'});
    // get template
    var tpl = dh.createTemplate({tag: 'li', id: 'item{0}', html: 'List Item {0}'});
    for(var i = 0; i < 5; i++)
    {
        tpl.append(list, [i]); // use template to append to the actual node
    }

我的猜测是,在调用 launch 时,您的应用实际上并未呈现到 dom。如果您将代码从启动移动到像 afterRender 这样的模板方法中会怎么样?

另外,我平时用得不多。您的应用程序是 Ext.Container 的一个实例,通常最简单的方法是向您自己添加组件并让 Ext 处理底层的 dom 交互。

文档中的此指南可能会有所帮助: https://help.rallydev.com/apps/2.1/doc/#!/guide/add_content