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 ...
随机推荐
- [Pytorch框架] 2.1.2 使用PyTorch计算梯度数值
文章目录 使用PyTorch计算梯度数值 Autograd 简单的自动求导 复杂的自动求导 Autograd 过程解析 扩展Autograd import torch torch.__version_ ...
- Centos7.x 安装配置jdk与jmeter
一.准备 1.jmeter(下载地址:https://jmeter.apache.org/download_jmeter.cgi) 2.jdk(下载地址:https://www.oracle.com/ ...
- SPSS计算极值、平均值、中位数、方差、偏度、峰度、变异系数
本文介绍基于SPSS软件的经典统计学分析与偏度.峰度等常用统计学指标的计算方法. 首先需要说明,本文所述数据的经典统计学分析,包括计算数据的极值.平均值.中位数.标准差.方差.变异系数.偏度与 ...
- 京喜APP - 图片库优化
作者:京东零售 何骁 介绍 京喜APP早期开发主要是快速原生化迭代替代原有H5,提高用户体验,在这期间也积累了不少性能问题.之后我们开始进行一些性能优化相关的工作,本文主要是介绍京喜图片库相关优化策略 ...
- React笔记-组件通信(六)
React笔记-组件通信(六) props概念 props是组件之间通讯的纽带 props也是组件中内置的一个属性 通过父级组件传入 在类组件里 可以直接通过this.props获取 注意: prop ...
- percona-server-rocksdb-8.0.32 安装
MyRocks是关系型数据库Mysql 基于RocksDB 的存储引擎,一个可嵌入的.持久的键值存储.Percona MyRocks 是集于 Percona Server for MySQL的. Ro ...
- 2022-11-02:以下go语言代码输出什么?A:编译错误;B:apple;C:ant;D:panic。 package main import “fmt“ func main() {
2022-11-02:以下go语言代码输出什么?A:编译错误:B:apple:C:ant:D:panic. package main import "fmt" func main( ...
- 2021-04-25:给定一个数组arr,和一个正数M,返回在arr的子数组在长度不超过M的情况下,求最大的累加和。
福大大 答案2021-04-25: 前缀和+左大右小的双端队列.时间太晚了,所以写得简单. 代码用golang编写.代码如下: package main import ( "containe ...
- KubeCon EU 2023 落幕,哪些技术趋势值得关注?
KubeCon+CloudNativeCon 是云原生领域的技术盛会,上个月月末,在荷兰阿姆斯特丹举办的欧洲 KubeCon+CloudNativeCon 刚刚落下帷幕,此次大会吸引了10000多名参 ...
- idea过期解决
用作用作发现过期了,苦恼,好办直接 搞个code 就行 MNQ043JMTU-eyJsaWNlbnNlSWQiOiJNTlEwNDNKTVRVIiwibGljZW5zZWVOYW1lIjoiR1VPI ...