I saw in a javascript code written by a young guy this function
我在一个年轻人写的javascript代码中看到了这个函数
function foo(e:MouseEvent){
...
}
I want to now what does e:MouseEvent do?
我想现在e:MouseEvent做什么?
1 个解决方案
#1
9
'e:MouseEvent' is a named parameter with a type declaration in typescript. A colon is used in typescript parameters to bind a parameter to a specific type which, in this case, is type 'MouseEvent'.
'e:MouseEvent'是一个命名参数,在typescript中有一个类型声明。在typescript参数中使用冒号将参数绑定到特定类型,在这种情况下,类型为“MouseEvent”。
e is often used as the parameter name for a javascript event. Given the type it's likely a function that responds to a click event.
e通常用作javascript事件的参数名称。鉴于它的类型,它可能是一个响应click事件的函数。
You can read more details about the syntax for it under the 'Function Types' heading of TypeScript's official documentation: https://www.typescriptlang.org/docs/handbook/functions.html.
您可以在TypeScript官方文档的“函数类型”标题下阅读有关其语法的更多详细信息:https://www.typescriptlang.org/docs/handbook/functions.html。
#1
9
'e:MouseEvent' is a named parameter with a type declaration in typescript. A colon is used in typescript parameters to bind a parameter to a specific type which, in this case, is type 'MouseEvent'.
'e:MouseEvent'是一个命名参数,在typescript中有一个类型声明。在typescript参数中使用冒号将参数绑定到特定类型,在这种情况下,类型为“MouseEvent”。
e is often used as the parameter name for a javascript event. Given the type it's likely a function that responds to a click event.
e通常用作javascript事件的参数名称。鉴于它的类型,它可能是一个响应click事件的函数。
You can read more details about the syntax for it under the 'Function Types' heading of TypeScript's official documentation: https://www.typescriptlang.org/docs/handbook/functions.html.
您可以在TypeScript官方文档的“函数类型”标题下阅读有关其语法的更多详细信息:https://www.typescriptlang.org/docs/handbook/functions.html。