在 TS 代码中使用 jQuery 等库时配合插件使用,但是插件的开发人员并没有为其扩展 jQuery 的类型定义,这是使用插件的方法必然会报 TS 的类型错误,这时候要快速选择忽略该报错的最直接的方法就是使用 any

如下:

($('.modal') as any).showModal(true)

但这种办法并不推荐,虽然短期内好用,但是时间长了难免会导致到处都是any,尤其多人开发时别人看到你写了个 any 那么他也会实用 any, 之后项目中的 any 就会像病毒一般扩散开来。

所以建议还是寻找怎样给不是自己的插件添加类型定义的方法,我后面也会继续寻找,如果有人找到了也希望能够告知一声,感激不尽!

Property 'showModal' does no t exist on type 'JQuery<HTMLElement>'的更多相关文章

  1. 在angular项目中使用bootstrap的tooltip插件时,报错Property 'tooltip' does no t exist on type 'JQuery<HTMLElement>的解决方法和过程

    在angular4的项目中需要使用bootstrap的tooltip插件. 1. 使用命令安装jQuery和bootstrap npm install bootstrap jquery --save ...

  2. TypeScript 错误property does not exist on type Object

    TypeScript 错误property does not exist on type Object 在TypeScript中如果按JS的方式去获取对象属性,有时会提示形如Property 'val ...

  3. 解决TS报错Property 'style' does not exist on type 'Element'

    在使用queryselector获取一个dom元素,编译时却报错说property 'style' does not exist on type 'element'. 原因:这是typescript的 ...

  4. react中使用typescript时,error: Property 'setState' does not exist on type 'Home'

    问题描述: 我在react中用typescript时,定义一个Home组件,然后在组件里用setState时会有这样一个报错:(如图)Property 'setState' does not exis ...

  5. Property 'validate' does not exist on type 'Element | Element[] | Vue | Vue[]'. Property 'valid...

    使用vue-cli 3.0+Element-ui时候,调用form表单校验时候出现的问题是: Property 'validate' does not exist on type 'Element | ...

  6. React报错之Property 'X' does not exist on type 'HTMLElement'

    正文从这开始~ 总览 在React中,当我们试图访问类型为HTMLElement 的元素上不存在的属性时,就会发生Property 'X' does not exist on type 'HTMLEl ...

  7. React报错之Property 'value' does not exist on type 'HTMLElement'

    正文从这开始~ 总览 当我们试图访问一个类型为HTMLElement的元素上的value属性时,会产生"Property 'value' does not exist on type 'HT ...

  8. React报错之Property 'value' does not exist on type EventTarget

    正文从这开始~ 总览 当event参数的类型不正确时,会产生"Property 'value' does not exist on type EventTarget"错误.为了解决 ...

  9. select2取值报错,Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('hidden') does not support selection.

    用到了 select2 组件来多选收件人,用搜狗浏览器(6.2版高速模式)在执行到如下这句时报错(Uncaught InvalidStateError: Failed to read the 'sel ...

随机推荐

  1. git远程相关

    git remote add origin git仓库地址 // 添加了远程仓库 git remote remove origin // 移除远程仓库 git push -u origin maste ...

  2. echarts 有关饼形图和map的使用技巧1(饼图)

    http://blog.csdn.net/yhn1121/article/details/52041742 先上个链接,百度无意间搜到的,写得比我全面,可以直接飞去看它: 之前写网页用过echarts ...

  3. Java连接MQTT服务-ws方式

    特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过.如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处:http://www.cnblogs.com/ ...

  4. Python遍历列表删除多个元素或者重复元素

    在遍历list的时候,删除符合条件的数据,结果不符合预期   num_list = [1, 2, 2, 2, 3] print(num_list) for item in num_list: if i ...

  5. LeetCode 11. 盛最多水的容器(Container With Most Water)

    题目描述 给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) .画 n 条垂直线,使得垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0).找出其中的两 ...

  6. 一、基础篇--1.1Java基础-HTTP请求的GET与POST方式的区别【转】

    http://www.cnblogs.com/logsharing/p/8448446.html 转载的这篇文章,很有意思,说的也很全面,学习下,防丢失,备份记录下 GET和POST是HTTP请求的两 ...

  7. zoopkeeper 的ACL操作

    1.创建一个变量存放模式信息, private static final String MODE = "digest"; //ACL模式   2.在一个类的构造函数内放入初始化信息 ...

  8. SpringBoot 启动流程

    SpringBoot 启动流程 加载 resources/META-INF/spring.factories 中配置的 ApplicationContextInitializer 和 Applicat ...

  9. kotlin之字符类型

    kotlin语言中,字符类型用Char表示,与java区别在于,kotlin中字符不能直接看成数字,如下: java中: void check (char c){ if(c==97){ } } kot ...

  10. idea -- spring datasource配置文件不显示datasource.properties文件对应属性的值,错误提示cannot resolve property key

    原文:https://yq.aliyun.com/articles/657711 点击 文件 顶部的 蓝色 MVC application context,修改为Local File