[typescript] Basic use of Typescript enumeration types

1. Typescript enumeration type

// create enumeration

enum myenum {  up , Down ,  left , Right }

// use enum type

function numtion (event: myenum ) {

   console.log(event)

}

numtion(myenum .left)

describe:

1. Use enum to define enumeration

2. It is agreed that the enumeration name starts with a capital letter

3. Pass between multiple values ​​in the enumeration, separated by commas

4. After defining the enumeration, use the enumeration name directly as the type annotation


 

Guess you like

Origin blog.csdn.net/m0_64494670/article/details/129269995