[英]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.