解析器返回未填充的承诺'Dojo中的错误

'Parser returned unfilled promise' error in Dojo

本文关键字:Dojo 错误 承诺 返回 填充      更新时间:2023-09-26

在我的代码中使用dojo/parser时,我得到以下错误:

parser returned unfilled promise (probably waiting for module auto-load), unsupported by _WidgetsInTemplateMixin.

define([
    "dojo/_base/declare",
    "dijit/_WidgetBase",
    "myApp/base/_TemplatedMixin",
    "dijit/_WidgetsInTemplateMixin",
    "dojo/text!../templates/MyTemplate.html",
    "dojo/i18n!../nls/Localized",
    "myApp/js/utils/hint",
    "dijit/form/ValidationTextBox",
    "dijit/form/SimpleTextarea",
    "dijit/form/Button",
    "dojo/parser",
    "dojo/domReady!"
], function (
    declare,
    _WidgetBase,
    _TemplatedMixin,
    _WidgetsInTemplateMixin,
    template,
    l10n,
    hint
) {
    'use strict';
    /**
     * @module
     */
    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
        widgetsInTemplate: true,
        /**
         * @description Localized object for view
         * @type {object}
         */
        l10n: l10n,
        /**
         * @description Custom template for view
         * @override
         */
        templateString: template,

        //postCreate: function () {
            //hint(l10n.hint);
        //}
    });
});

我做了一些研究,意识到这可能与依赖关系和顺序有关。我已经添加了widgetsIntemplate属性,但仍然没有骰子。这只发生在第一次加载页面时。

有人能帮忙吗?

如果你的模板中有小部件,你必须确保它们都是预加载的。确保您的定义包含模板中的所有小部件。

对于将来的读者:当在模板中创建一个小部件由于任何其他原因失败时,也可能抛出此错误消息。

例如,我在模板中有一个dijit/form/FilteringSelect,并且在传递给它的store属性的变量中有一个错字。所以store是undefined

有时很难找到这个错误消息的来源。

  1. 依次从模板中删除部件,以确定导致问题的部件。
  2. 在您自己的buildRendering函数中的try-catch块中以编程方式实例化小部件,以查看实际出错的地方。