在Dojo中创建自定义窗口小部件时出现错误,无法确定错误原因

问题描述 投票:0回答:1

我创建了一个自定义窗口小部件,用于在您单击图标时显示工具提示。当我添加其他窗口小部件的模板时,出现以下错误:“ dojo / parser.js:900 dojo / parser :: parse()错误错误:无法解析构造函数:'CustomPopup'”。我在这里附上我的代码。 CustomPopup是用于显示工具提示的小部件。 (html和js都在同一目录中)

CustomPopup.html

  <span id="${id}"   data-dojo-attach-event="onclick: myClickHandler, mouseout: myMouseOut"></span>

CustomPopup.js

define([       
        'dijit/_WidgetBase',
        'dijit/_TemplatedMixin',
        'dijit/_WidgetsInTemplateMixin',  
        'dojo/_base/declare',
        'dojo/on',
        'dijit/registry',
        'dijit/TooltipDialog',
        'dijit/popup',
        'dojo/mouse',
        'dojo/dom',
        'dijit/_AttachMixin',
        'dojo/text!./CustomPopup.html',
        'dojo/parser'

        ],function(  _WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin, declare,on,registry,TooltipDialog,popup,mouse,dom,_AttachMixin,htmlTemplate,
                    parser)
{
return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,TooltipDialog],{


           templateString    : htmlTemplate,


           myClickHandler: function(e){
                            console.log('hiiii');
                           },
           myMouseOut: function(){
                           console.log('bhhhh');
                           },

_toolTipDialog : null    

            });
        });

我将此小部件添加到另一个小部件以获取工具提示,即HTMLtemplate为

somewidget:

<div id="mainId" data-dojo-type="dijit/layout/ContentPane" style="width:100%; height:100%">
    <div data-dojo-type="dijit/form/TextBox" data-dojo-props='diaplayedValue:"10"' id="jet" style="background-color: red;"></div>
    <div data-dojo-type="dijit/form/TextBox" data-dojo-props='displayedValue:"20"' id="jet1" style="background-color: blue;"></div>
    <div  data-dojo-type="CustomPopup" id="klm"></div>

</div>

我收到以下错误:enter image description here

更多信息enter image description here

所以,有人可以帮忙解决我的错误。

javascript dojo dojox.grid.datagrid dojox.grid dojo.gridx
1个回答
0
投票

您永远不要对dojo小部件使用id。请使用data-dojo-attach-point代替

© www.soinside.com 2019 - 2024. All rights reserved.