[英]The property 'jqGrid' does not exist on value of type 'JQuery'
I am using Typescript with jqGrid and jQuery. 我正在使用带有jqGrid和jQuery的Typescript。
On the following line: 在以下行:
jQuery(this).jqGrid('editGridRow', rowid, {
...
I get the message: 我收到消息:
The property 'jqGrid' does not exist on value of type 'JQuery'.
属性'jqGrid'在'JQuery'类型的值上不存在。
Any ideas on how to correct this problem? 关于如何纠正这个问题的任何想法?
I suppose that you use jquery.TypeScript.DefinetlyTyped NuGet Package. 我想你使用jquery.TypeScript.DefinetlyTyped NuGet包。
In that case add file ~/Scripts/typings/custom.d.ts with following content: 在这种情况下,添加文件〜/ Scripts / typings / custom.d.ts ,内容如下:
/// <reference path="jquery/jquery.d.ts"/>
interface JQuery { jqGrid: any; }
Update: Above solution is general and works in all cases. 更新:以上解决方案是通用的,适用于所有情况。 Better solution is to...
更好的解决方案是......
Install jqgrid.TypeScript.DefinitelyTyped NuGet Package. 安装jqgrid.TypeScript.DefinitelyTyped NuGet包。
The problem is that JQuery grid is a plugin. 问题是JQuery网格是一个插件。 It seems like you have a definition file for the JQuery library but not for the JQuery Grid plugin.
看起来你有一个JQuery库的定义文件,但没有JQuery Grid插件的定义文件。 I checked on https://github.com/borisyankov/DefinitelyTyped and there does not appear to be a type definition for this particular plugin.
我检查了https://github.com/borisyankov/DefinitelyTyped ,似乎没有这个特定插件的类型定义。 There are a few things you could do.
你可以做一些事情。
var localJq : any = jQuery(this); var localJq:any = jQuery(this); localJq.jqGrid('editGridRow', rowid, { ... });
localJq.jqGrid('editGridRow',rowid,{...});
This will fool the compiler and let you access properties on the var that are not defined in a definition file. 这将欺骗编译器,并允许您访问var中未在定义文件中定义的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.