感觉会C++就跟孔乙己似的
走到人群里 问到
“你们知道虚函数表解决了什么问题么?”
众人纷纷议论
“那你们知道const加什么关键字能修改么”
众人哄笑 你都用const了你修改干啥
“那你们知道在类内声明函数的类型么”
众人作鸟兽散 不愿表现得同这人熟悉
只剩下一人喃喃
“inline inline ”
配图孔乙己本人
走到人群里 问到
“你们知道虚函数表解决了什么问题么?”
众人纷纷议论
“那你们知道const加什么关键字能修改么”
众人哄笑 你都用const了你修改干啥
“那你们知道在类内声明函数的类型么”
众人作鸟兽散 不愿表现得同这人熟悉
只剩下一人喃喃
“inline inline ”
配图孔乙己本人
//模块:
/*
如果在typescript文件的根位置含有import 与export,那么就会在这个文件中创建一个本地作用域
*/
/*
export const a= 1;
在另一个文件中:
import {a} from './文件名';
*/
//ES模块语法:
const num = 123;
type User = {
type: string;
};
export {num, User};
//也可以以重命名变量的方式导出:
export {num as numb, User as user};
/*
在另一个文件中:
import {user, numb} from './文件名';
或:
import{User as user, num as, numb}from './文件名';
*/
//也可以使用整体加载;
/*
import * as other from './文件名';
可以通过此 导出任意该文件中变量或类型;
other.User;
other.num;
*/
/*
也可以只导入模块;
import './文件名';
从其他模块导入以后整体导出:
export *from './文件名';
从其他模块导入后,部分导出:
export {user} from './文件名';
通过重命名部分导出从另一个模块导入的项目;
export {User as user} from './文件名'
*/
//默认导出: export default
//使用 import someName from 'someModule' 语法,可以为需要的导入命名
/*
如果在typescript文件的根位置含有import 与export,那么就会在这个文件中创建一个本地作用域
*/
/*
export const a= 1;
在另一个文件中:
import {a} from './文件名';
*/
//ES模块语法:
const num = 123;
type User = {
type: string;
};
export {num, User};
//也可以以重命名变量的方式导出:
export {num as numb, User as user};
/*
在另一个文件中:
import {user, numb} from './文件名';
或:
import{User as user, num as, numb}from './文件名';
*/
//也可以使用整体加载;
/*
import * as other from './文件名';
可以通过此 导出任意该文件中变量或类型;
other.User;
other.num;
*/
/*
也可以只导入模块;
import './文件名';
从其他模块导入以后整体导出:
export *from './文件名';
从其他模块导入后,部分导出:
export {user} from './文件名';
通过重命名部分导出从另一个模块导入的项目;
export {User as user} from './文件名'
*/
//默认导出: export default
//使用 import someName from 'someModule' 语法,可以为需要的导入命名
//类型申明空间与变量申明空间
/*
类型申明空间:
可以当作类型注解使用,但是并不能当作变量使用 :const a: example; 是错误的;
*/
class example{
};
interface example1{
};
type example2 = {};
let a: example;
let b: example1;
let c: example2;
const d = example;
const e = 123;
/*
申明变量空间不能当作类型注解使用
*/
/*
类型申明空间:
可以当作类型注解使用,但是并不能当作变量使用 :const a: example; 是错误的;
*/
class example{
};
interface example1{
};
type example2 = {};
let a: example;
let b: example1;
let c: example2;
const d = example;
const e = 123;
/*
申明变量空间不能当作类型注解使用
*/
✋热门推荐