This is the 14th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021
preface
As you learn about Vue3. X, it’s inevitable (and optional) to use TypeScript. The process of learning TypeScript is documented here in TypeScript In Action
Review previous article: You learned about TS initialization, installation, creating TS projects, compiling and running, and getting to know the world of TS type constraints: TypeScript vs. JavaScript raw data types
1. The Typescript document
The Typescript website address: www.typescriptlang.org/zh/
Typescript documentation address: Basic Types
TypeScript several primitive data types
TypeScript provides all the functionality of JavaScript and adds a layer on top of it: TypeScript’s type system.
TypeScript offers all of JavaScript’s features, and an additional layer on top of these: TypeScript’s type system.
- Boolean type:
boolean
- Number type:
number
- String type:
string
- Null:
void
- BigInt Specifies the type of a large integer.
bigint
- Null, and Undefined:
null
和undefined
By default, null and undefined are subtypes of all types and can be assigned to strings, etc - Symbol type:
symbol
Boolean Indicates the Boolean type
const isDone: boolean = false
Copy the code
String string
let name: string = 'xn213'
Copy the code
Void a null value
When wrapping a function, a common function that does not return a value is defined as void.
function nothingReturn() :void {
alert('this is a function with nothing to return')}Copy the code
Symbol type
Symbol is created using the Symbol constructor and is a new primitive type after ES2015:
const s1 = Symbol('s1')
const s2 = Symbol('s2')
Symbol('s1') = = =Symbol('s1') // false
Copy the code
/// and the value of Symbol is unique:
Vue3 learning actual combat series more text:
- Vue3 source code learning tool utils(2)
- Vue3- Initial experience,
- Vue3- Life cycle and setup() function,
- Vue3-
computed & watch
, - Vue3-teleport changes the root node to which the component is mounted,
- Vue3-Suspense for asynchronous requests,
- Vue3-defAsyncComponent Asynchronous component (new),
- Vue3- Fragments (new),
- Vue3-v-model (not compatible),
- Vue3 source repository
vue-next
: Github.com/vuejs/vue-n… - Vue3.x Official Chinese document: v3.cn.vuejs.org
- TypeScript series:
- Getting to know TypeScript – Enter the world of TS type constraints