自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

原创 Koa插件使用

1.基本使用const Koa = require("koa"); // 获取koaconst bodyParser = require("koa-bodyparser"); // body中间件// const static = require("koa-static"); // 静态服务器中间件const path = require("path");const KoaRouter = require("@koa/router"); // 路由包const views= require(

2020-12-31 16:40:59 372

原创 Ts的接口

1.对json进行限制interface JsonFomat { name: string; // 必须存在name readonly age: number; // 必须存在age [propName: string]: any; //其他属性,可有可无}let json1: JsonFomat = { name: "张三", age: 18,};let json2: JsonFomat = { name: "张三", age: 18, defineName

2020-12-31 15:30:06 390

原创 Ts的类

1.修饰符public 公有 父类(自身)以及子类和外部都能访问protected 受保护 父类(自身)以及子类都能访问 但是外部不能访问private 私有的 父类(自身)可以访问 但是子类和外部不能访问2.基本使用class Person { // name: string; static age: number = 18; // 静态属性 // constructor(name: string) { // this.name = name;

2020-12-31 15:23:57 603

原创 Ts的函数

1.函数匿名函数void无返回值function f1(): void { console.log(1);}let f2 = function (): void { console.log(1);}; // 匿名函数// type 定义类型别名type F22 = (x: string, y: number) => string;let f22: F22 = function (a, b) { return a + b;};let f222: F22 = f...

2020-12-31 15:19:47 809

原创 Ts的数据类型

1.booleanlet flag: boolean = true;2.numberlet a: number = 1;3.stringlet str: string = "这是个字符串";4.arraylet arr1: number[] = [1, 2, 3];let arr2: Array<number> = [1, 2, 3];5.元组[定义数组每一项的类型,一般可以用any替代]let arr3: [number, string] = .

2020-12-31 15:15:30 1365

原创 nodejs的http

1.http的常规使用const http = require("http");const urlPkg= require("url");const server = http.createServer((req, res) => { if(req.url==='/favicon.ico') return; const method= req.method.toLowerCase(); // 获取请求的方法 const url= urlPkg.parse(req.url,tru

2020-12-10 14:49:09 175

原创 nodejs的文件流 stream

1.文件可读流const fs= require("fs");const stm =fs.createReadStream("./file.txt",{ flags: "r", // 读取模式 autoClose: true, // 读取完毕自动关闭流 emitClose: true, start: 3, // 开始位置 end: 11, // 结束位置 highWaterMark: 6 // 一次文件读取的最大量【内存开辟大小】});l

2020-12-10 14:29:48 1090

原创 commander的使用和npm的介绍

1.commanderconst commander = require("commander"); // 第三方包const chalk = require("chalk");console.log(chalk.green("====参数的解析和commander的简单使用===="));commander.name("node"); // 名字介绍commander.usage("<path file>"); // 使用方式介绍commander.version("1.0.

2020-12-10 14:11:42 3998 1

原创 nodejs的events事件

1.events的使用const EventEmitter = require("events");const util = require("util");// const event = new EventEmitter(); //这是直接实例化eventsfunction Man() {}util.inherits(Man, EventEmitter); // 实现原型的继承const event = new Man(); // 区别到具体的类,实例化类event.o

2020-12-10 13:50:57 267

原创 nodejs的Buffer

1.buffer常用方法// nodejs的中文是三个字节let buf = Buffer.from("珠峰"); // 参数是string 建立内存空间let buf1 = buf.slice(0, 3); // 截取内存console.log(buf1); // <Buffer e7 8f a0>console.log(buf1.toString()); // 珠buf1[0] = 100; // 这里修改了第一个字节console.log(buf1); // <

2020-12-10 13:41:07 261 1

原创 nodejs的Fs模块

1.读文件const fs = require("fs");const path = require("path");const resolve = (url) => path.resolve(__dirname, url);// 同步读取function readWriteFileSync(path, wPath) { let content; try { content = fs.readFileSync(path); // 读取内容 fs.appendF

2020-12-10 11:34:11 222

原创 nodejs常用全局变量

1.processconst chalk = require("chalk"); //第三方包,让console有颜色console.log(chalk.green("====常见全局变量的演示===="));console.log( process.platform, chalk.grey("平台 一般是win32(windows)和darwin32(os,mac)"));console.log(process.env.JAVA_HOME, chalk.grey("环境变量 env

2020-12-10 11:21:19 613

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除