TypeScript Property ‘XXX‘ does not exist on type ‘never‘.
开发过程中出现这个错误是因为Typescript在执行代码检查时在该对象没有定义相应属性,这个错误不致命,遇到该错误有以下几种解决办法。
1,将对象设置成 any
this.targetArray = this.options.find((item:any) => {return item.articleId == val;});
2,通过字符方式获取对象属性
this.targetArray = this.options.find((item) => {return item["articleId"] == val;});
3,声明断言,强制执行
this.targetArray = this.options.find((item) => {return (item as any).articleId == val;});
TypeScript Property ‘XXX‘ does not exist on type ‘never‘.相关推荐
- property xxx does not exist on type Object报错
在TypeScript中如果按JS的方式去获取对象属性,有时会提示形如Property 'xxx' does not exist on type 'Object'的错误.下文代码中的'xxx'替换成你 ...
- 完美解决:Property ‘XXX‘ does not exist on type ‘Window‘
发生情景: 在app中的h5,app注入了全局的window对象和webview里面的页面交互,打包的时候报了错误. 解决方式: 方法一: (window as any).xxx 方法二: decla ...
- Property ‘xxx‘ does not exist on type ‘{ xxx(file: any, fileList: any): void;的报错
关闭tsconfig.json里的"strict",把 true 改为 false 即可
- 响应式编程时出现:error TS2339: Property 'debounceTime' does not exist on type 'Observableany'.
constructor() {this.searchInput.valueChanges//.debounceTime(500) 无法使用.pipe(debounceTime(1000)).subsc ...
- Angular响应式开发中报错Property 'map' does not exist on type 'Observable'.引用rxjs也没用。
Angular响应式开发源代码如下: import { Component, OnInit } from '@angular/core'; import {Observable} from 'rxjs ...
- Property ‘next‘ does not exist on type ‘Component<any, {}, any>‘问题的解决方法
场景:使用antd的Carousel组件时,自定义左右切换按钮,触发组件的next(),prev()方法时报错 错误写法: handleNext(){this.refs.img.next()}< ...
- TS2550: Property ‘entries‘ does not exist on type ‘ObjectConstructor‘.
问题:TS2550: Property 'entries' does not exist on type 'ObjectConstructor'. Do you need to change your ...
- Property ‘contentWindow‘ does not exist on type HTMLElement,类型htmlelement上不存在contentwindow属性
一.问题 Property 'contentWindow' does not exist on type HTMLElement 二.解决方法 /*** Property 'contentWindow ...
- Property ngOnInit does not exist on type VisibleFocusDirective
原因是我把Base focus Directive的OnInit函数删除了: 添加上之后问题消失: 更多Jerry的原创文章,尽在:"汪子熙":
最新文章
- 重写 equals 方法就一定要重写 hashCode 方法?其实有个前提
- python多线程爬虫实例-python 多线程爬虫 实例
- codevs 1082 线段树区间求和
- 如何去掉手机php,dedecms怎么关闭手机版
- 网络分层模型OSI和TCP/IP四层模型
- 将svg文件化成字体图标的步骤
- Qt Creator在问题窗格中显示任务列表文件
- 2019.01.29【NOIP普及组】模拟赛C组总结
- android动态加home,Android 解决监听home键的几种方法
- 动态卷积:自适应调整卷积参数,显著提升模型表达能力 CVPR 2020
- 安卓Dialog弹出对话框全解:包含了AlertDialog,DialogFragment
- hadoop集群免密码登陆
- 快二游戏数据分析_1.更快的数据分析
- 联想笔记本怎么进入pe系统_联想笔记本电脑怎么进入PE?
- 怎么修改PDF文件中的图片以及文字
- 前Google工程师Levandowski跳入优步监狱
- 基于eigen实现matlab hamming hann blakman 窗函数的实现
- iOS苹方字体使用说明
- 03.mysql调优--索引基本实现
- 【Win10】电脑麦克风录音:设备调测