[英]ERROR TypeError: "jit_nodeValue_3(...).toggle is not a function"
I'm working on an Angular project.我正在从事 Angular 项目。 I wanted to add a month picker that would turn up on click of a text field at the nav bar.我想添加一个月份选择器,它会在点击导航栏上的文本字段时出现。 I'm using primeng
components like <p-calendar>
and <p-overlay>
.我正在使用像<p-calendar>
和<p-overlay>
这样的primeng
组件。 Its a huge project in itself and I've to add calendar
widget.它本身就是一个巨大的项目,我必须添加calendar
小部件。 So I'll show you my part of code only.所以我只会向您展示我的部分代码。
navigation.component.html导航.component.html
<div class="dls-menu-item" style="float: right; margin-right: 200px;">
<input type="text" (click)="op.toggle($event)">
</div>
<p-overlayPanel #op>
<div id="comp-render">
<div class="all-container">
<p>Time selection</p><br>
<div>
<p-calendar view="month" dateFormat="mm/yy"...></p-calendar>
</div>
<br>
</div>
</div>
</p-overlayPanel>
But the moment I click on the input field, I get this error:但是当我点击输入字段时,我得到了这个错误:
My research on this error says that it is related to MD Bootstrap
.我对这个错误的研究表明它与MD Bootstrap
有关。 But this answer is not working for me.但是这个答案对我不起作用。 I also tried this technique but it's not performing the way we want.我也尝试过这种技术,但它没有按照我们想要的方式执行。 And my findings says that (click)="op.toggle($event)
is the root cause. Please tell me how to solve this.我的发现表明(click)="op.toggle($event)
是根本原因。请告诉我如何解决这个问题。
Sorry for late reply can you try to create typings.d.ts and put this code here into it抱歉回复晚了,您可以尝试创建 typings.d.ts 并将此代码放入其中吗
interface JQuery<any> {
tooltip(params: any): any;
}
Then in your tsconfig.json然后在你的 tsconfig.json
"typeRoots": [
"node_modules/@types",
"src/typings.d.ts" // add here
],
This happens when you try to trigger the popover toggle from a non-prime element.当您尝试从非主要元素触发弹出框切换时会发生这种情况。 It appears you need to add pInput to the input (or div and move the click handler) and then it will work.看来您需要将 pInput 添加到输入(或 div 并移动单击处理程序),然后它将起作用。
<div class="dls-menu-item" style="float: right; margin-right: 200px;">
<input type="text" (click)="op.toggle($event)" pInput><!--Add pInput-->
</div>
<p-overlayPanel #op>
<div id="comp-render">
<div class="all-container">
<p>Time selection</p><br>
<div>
<p-calendar view="month" dateFormat="mm/yy"...></p-calendar>
</div>
<br>
</div>
</div>
</p-overlayPanel>
Please check that ngx-menu is imported in your module in which you are using it.请检查 ngx-menu 是否已导入您使用它的模块中。
I recently encountered console error jit_nodevalue_3(...) is not a function while using Angular 7 and Mat-Menu .我最近在使用 Angular 7 和Mat-Menu时遇到控制台错误jit_nodevalue_3(...) is not a function 。
The reason behind this error was the mat-menu element being declared with the same name as a click handler function I was using.此错误背后的原因是 mat-menu 元素被声明为与我正在使用的单击处理程序 function 同名。
<mat-menu #onClickItem="matMenu">
<button mat-menu-item (click)="onClickItem()">Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
Renaming the click function solved the problem.重命名点击 function 解决了问题。
<button mat-menu-item (click)="doSomething()">Item 1</button>
Hope this helps someone.希望这对某人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.