随笔分类 - TypeScript
摘要:#typescript 学习笔记 申明全局类型,不用import导入,可以直接使用 项目更目录下创建typings目录 在typings中添加 index.d.ts, 在其中定义需要的类型 interface MyType { foo: string, bar: string[] } 修改 tsco
阅读全文
摘要:使用typescript封装axios 这个axios封装,因为是用在vue3的demo里面的,为了方便,在vue3的配置里面按需加载element-plus 封装axios http.ts import axios, { InternalAxiosRequestConfig, AxiosReque
阅读全文
摘要:node中express的,res.send() 或res.json()这类客户端返回的方法仅返回一次,如果多次返回就会出现这个错误! 一般是因为 if…else 判断时出错
阅读全文
摘要:在ts爬虫代码练习时,用cheerio来获取网页中数据时 const viewCountTemp = $(e).find('.postDesc').eq(idx).find('.post-view-count').text() // "阅读(5)" infoItem.viewCount = pars
阅读全文
摘要:1. 新建文件夹。 crowller 2. 在文件夹下,进行 npm init -y ,进行初始化,出现package.json文件。 3. 在文件夹下,进行 tsc --init , 新增typescript的配置文件 tsconfig.json 4. 安装typescript文件,ts-node
阅读全文
摘要:1. 简单创建一个class 类 1 class Person { 2 // name:string; 3 // constructor(name:string){ 4 // this.name = name 5 // } 6 // 简化写法 在构造器的参数前面加上 访问属性,就是默认添加一个参数名
阅读全文