简体   繁体   English

在 Dojo 中创建自定义小部件时遇到错误,无法确定错误原因

[英]facing error while creating custom widget in Dojo, could not identify the reason for the error

I have created a custom widget for showing tooltip while u click on a icon.我创建了一个自定义小部件,用于在您单击图标时显示工具提示。 When i add this template of other widget I am getting " dojo/parser.js:900 dojo/parser::parse() error Error: Unable to resolve constructor for: 'CustomPopup' " following error.当我添加其他小部件的这个模板时,我收到“ dojo/parser.js:900 dojo/parser::parse() 错误错误:无法解析构造函数:‘CustomPopup’”以下错误。 I am attaching my code here.我在这里附上我的代码。 CustomPopup is the widget for showing tooltip. CustomPopup 是用于显示工具提示的小部件。 (both html and js are in same directory) (html和js都在同一个目录下)

CustomPopup.html自定义弹出窗口

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

CustomPopup.js自定义弹出窗口.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    

            });
        });

I am adding this widget to another widget to get tooltip, that HTMLtemplate is我将此小部件添加到另一个小部件以获取工具提示,即 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>

I am getting the below error: enter image description here我收到以下错误:在此处输入图片说明

more info更多信息在此处输入图片说明

so ,could someone pls help to fix my error.所以,有人可以帮助修复我的错误。

You should never use id for dojo widgets.永远不要将 id 用于 dojo 小部件。 Use data-dojo-attach-point instead改用 data-dojo-attach-point

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM