简体   繁体   English

类型“ JQuery”上不存在属性“ kendoGrid” <HTMLElement>

[英]Property 'kendoGrid' does not exist on type 'JQuery<HTMLElement>

I am using VSCode editor for my angular project development. 我正在使用VSCode编辑器进行角度项目开发。 VSCode intellisense is working fine with @typings/kendo-ui. VSCode intellisense与@ typings / kendo-ui一起正常工作。 But, Webpack compilation failed due to the error. 但是,由于该错误,Webpack编译失败。

Error: 错误:

"Property 'kendoGrid' does not exist on type 'JQuery" “类型'JQuery不存在属性'kendoGrid'”

在此处输入图片说明

This error is same for all kendo components 此错误对于所有剑道组件均相同

I am using latest angular CLI for this project. 我正在为此项目使用最新的角度CLI。

Not sure if you got the answer already, but kendoGrid is jQuery dependent. 不知道您是否已经得到答案,但是kendoGrid是jQuery依赖的。 In addition to installing jQuery and the kendoGrid file, you should add your kendoGrid code in the ngAfterViewInit lifecyle hook in whatever component you are using like this : 除了安装jQuery和kendoGrid文件外,您还应该在ngAfterViewInit钩子中将kendoGrid代码添加到正在使用的任何组件中,如下所示:

  ngAfterViewInit(){
      $(document).ready(function(){
              // code to execute
              });
}

Also add declare var $:any; 还要添加declare var $:any; which declares the jQuery variable with any type. 声明任何类型的jQuery变量。 Assuming you added import * as $ from 'jquery' in your module file. 假设您在模块文件中import * as $ from 'jquery'中将import * as $ from 'jquery'添加import * as $ from 'jquery'

尝试这个

(<any>$("#grid")).kendoGrid()

if you are using Angular CLI the only import statement you need for a component.ts is 如果您使用的是Angular CLI,则component.ts所需的唯一import语句是

declare var $: any;

instead of import * as $ from 'jquery' and declare var $:any; 而不是import * as $ from 'jquery'declare var $:any;

and

  ngAfterViewInit(){
  $(document).ready(function(){
          // code to execute
          });

} }

暂无
暂无

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

相关问题 类型“JQuery”上不存在属性“slick”<HTMLElement> &#39; - Property 'slick' does not exist on type 'JQuery<HTMLElement>' 类型“JQuery”上不存在属性“模态”<HTMLElement> &#39; - Property 'modal' does not exist on type 'JQuery<HTMLElement>' 类型“JQuery”上不存在属性“掩码”<HTMLElement> - Property 'mask' does not exist on type 'JQuery<HTMLElement> 类型“JQuery”上不存在属性“排序”<htmlelement> '</htmlelement> - Property 'sort' does not exist on type 'JQuery<HTMLElement>' Angular 6导入JQVMap-类型&#39;JQuery不存在属性&#39;vectorMap&#39; <HTMLElement> “ - Angular 6 Importing JQVMap - Property 'vectorMap' does not exist on type 'JQuery<HTMLElement>' 类型“JQuery”上不存在属性“涟漪”<HTMLElement> &#39;。 在角分量 - Property 'ripples' does not exist on type 'JQuery<HTMLElement>'. in angular component Typescript 中的 jQuery:类型“JQueryStatic”上不存在属性“attr”<HTMLElement> &#39;.ts - jQuery in Typescript: Property 'attr' does not exist on type 'JQueryStatic<HTMLElement>'.ts 类型“ JQuery”上不存在如何删除属性“ queryBuilder” <HTMLElement> “ - How to remove Property 'queryBuilder' does not exist on type 'JQuery<HTMLElement>' 错误:类型“ JQuery”上不存在“可拖动”属性 <HTMLElement> “ - Error: Property 'draggable' does not exist on type 'JQuery<HTMLElement>' TS2339:属性&#39;selectpicker&#39;在类型&#39;JQuery上不存在 <HTMLElement> “ - TS2339: Property 'selectpicker' does not exist on type 'JQuery<HTMLElement>'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM