TypeScript: Object is of type 'unknown'.
错误代码展示

解决方案
将e声明为any类型,如下所示:

// 修改蛇的X和Y值
try {
this.snake.X = X;
this.snake.Y = Y;
}catch(e:any){
// 进入到catch,说明出现了异常,游戏结束,弹出一个提示信息
alert(e.message);
// 将isLive设置为false
this.isLive = false;
}
TypeScript: Object is of type 'unknown'.的更多相关文章
- [TypeScript] Union Types and Type Aliases in TypeScript
Sometimes we want our function arguments to be able to accept more than 1 type; e.g. a string or an ...
- TypeScript & Object Error
TypeScript & Object Error Element implicitly has an 'any' type because expression of type 'any' ...
- Type Unknown error: java.lang.NullPointerException
Android 项目开发的时候 出现: Description Resource Path Location Type Unknown error: java.lang.NullPointerExce ...
- [TypeScript] Infer the Return Type of a Generic Function Type Parameter
When working with conditionals types, within the “extends” expression, we can use the “infer” keywor ...
- The method format(String, Object[]) in the type String is not applicable for the arguments
今天,我弟遇到一个有意思的错误~ 程序: package com.mq.ceshi1; public class StringFormat { public static void main(Stri ...
- Can a C++ class have an object of self type?
A class declaration can contain static object of self type,it can also have pointer to self type,but ...
- Nuxt / Vue.js in TypeScript: Object literal may only specify known properties, but 'components' does not exist in type 'VueClass'
项目背景, Nuxt(vue), TypeScript 生成完项目框架, 添加测试demo页面. 在生成的模板代码中添加layout配置如下: <script lang="ts&quo ...
- 【区分】Typescript 中 interface 和 type
在接触 ts 相关代码的过程中,总能看到 interface 和 type 的身影.只记得,曾经遇到 type 时不懂查阅过,记得他们很像,相同的功能用哪一个都可以实现.但最近总看到他们,就想深入的了 ...
- Oracle Schema Objects(Schema Object Storage And Type)
One characteristic of an RDBMS is the independence of physical data storage from logical data struct ...
- [TypeScript] Define a function type
type DigitValidator = (char) => boolean; -]{}/.test(char); export const digitValidators: {[key: s ...
随机推荐
- vue中使用西瓜视频api
https://v2.h5player.bytedance.com/en/api/ 1 npm install xgplayer 1 <div id="mse">< ...
- IE盒模型和标准盒模型之间的差别
1.W3C标准盒子模型 w3c盒子模型的范围包括margin.border.padding.content,并且content部分不包含其他部分 2.IE盒子模型 IE盒子模型的范围包括margin. ...
- Python-HwTestReport的简单使用
一.工具包下载 https://github.com/hongweifuture/HwTestReport(出自此大神) 二.使用示例(直接上代码) 1.将 HwTestReport.py 导入项目 ...
- 快速傅里叶变换FFT学习笔记
点值表示法 我们正常表示一个多项式的方式,形如 \(A(x)=a_0+a_1x+a_2x^2+...+a_nx^n\),这是正常人容易看懂的,但是,我们还有一种表示法. 我们知道,\(n+1\)个点可 ...
- day10-好友关注
功能05-好友关注 6.功能05-好友关注 6.1关注和取关 6.1.1需求分析 在探店图文的详情页面中,可以关注发布笔记的作者: 关注和取关:点击关注按钮就会发出请求(上图):http://127. ...
- (亲自实践)解决安装weditor报错UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xad in position 825
升级weditor时,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 825: illegal multib ...
- Grafana 系列-统一展示-3-Prometheus 仪表板
系列文章 Grafana 系列文章 知识储备 Prometheus Template Variables 你可以使用变量来代替硬编码的细节,如 server.app 和 pod_name 在 metr ...
- 2022-04-23:给定你一个整数数组 nums 我们要将 nums 数组中的每个元素移动到 A 集合 或者 B 集合中 使得 A 集合和 B 集合不为空,并且 average(A) == aver
2022-04-23:给定你一个整数数组 nums 我们要将 nums 数组中的每个元素移动到 A 集合 或者 B 集合中 使得 A 集合和 B 集合不为空,并且 average(A) == aver ...
- 2022-11-19:第二高的薪水。表结构和数据的sql语句如下,输出200,因为200是第二大的。请问sql语句如何写? DROP TABLE IF EXISTS `employee`; CREAT
2022-11-19:第二高的薪水.表结构和数据的sql语句如下,输出200,因为200是第二大的.请问sql语句如何写? DROP TABLE IF EXISTS `employee`; CREAT ...
- Qt+QtWebApp开发笔记(五):http服务器html中使用json触发ajax与后台交互实现数据更新传递
前言 前面完成了页面的跳转.登录,很多时候不刷新页面就想刷新局部数据,此时ajax就是此种技术,且是异步的. 本篇实现网页内部使用js调用ajax实现异步交互数据. 在js中使用 ajax是通 ...