构建以下打字稿代码时出现以下错误。
Property 'runStaticMethod' is a static member of type 'DemoClass'
Run Code Online (Sandbox Code Playgroud)
打字稿代码:
Property 'runStaticMethod' is a static member of type 'DemoClass'
Run Code Online (Sandbox Code Playgroud)
console构建上述typescript代码时出现以下错误。但是javascript代码按预期运行。
控制台错误:
Chitty:tsc NatarajanG$ tsc
src/index.ts:5:19 - error TS2576: Property 'runStaticMethod' is a static member of type 'DemoClass'
5 this.demo.runStaticMethod();
~~~~~~~~~~~~~~~
Chitty:tsc NatarajanG$
Run Code Online (Sandbox Code Playgroud) 如何在打字稿中获取对象的哈希值。
例如 :
let user:any = {name:'tempuser', age:'29'};
let anotheruser:any = {name:'iam', age:'29'};
if( Object.GetHashCode(user) === Object.GetHashCode(anotheruser)){
alert('equal');
}
Run Code Online (Sandbox Code Playgroud)
我们还可以识别对象是否被修改。