随笔分类 -  TypeScript

ts相关问题
摘要:初始化Demo需要的文件 初始化tsconfig.json文件 tsc --init 初始化package.json文件 npm init 使用rollup打包,packge.json文件中加入依赖 { "scripts": { "test": "echo \"Error: no test spec 阅读全文
posted @ 2023-04-17 18:25 泠风lj 阅读(78) 评论(0) 推荐(0) 编辑
摘要:在 TypeScript 中,? 符号用于表示可选属性或可选参数。当 ? 符号放在类型的前面时,表示该类型为可选类型。当 ? 符号放在变量或参数的后面时,表示该变量或参数是可选的,可以不传值。因此,?string 和 string? 表示的含义是不同的。?string 表示一个可选的字符串类型,即这 阅读全文
posted @ 2023-03-29 13:11 泠风lj 阅读(588) 评论(0) 推荐(0) 编辑
摘要:class 类的get和set ts在编译get和set的时候默认是es3编译,vscode编辑器会报错error TS1056: Accessors are only available when targeting ECMAScript 5 and higher需要编译到版本ES5或以上,解决办 阅读全文
posted @ 2023-03-26 01:25 泠风lj 阅读(100) 评论(0) 推荐(0) 编辑
摘要:效果 HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" con 阅读全文
posted @ 2023-03-17 02:20 泠风lj 阅读(73) 评论(0) 推荐(0) 编辑
摘要:方式一:ts 手动编译成 js 先安装ts npm install -g typescript 检测版本 tsc -v ts 编译成 js 1.新建 ts 文件夹,使用 vscode 打开,新建 index.ts,代码如下 (() => { const username: string = "小明" 阅读全文
posted @ 2023-03-16 16:28 泠风lj 阅读(2704) 评论(0) 推荐(0) 编辑
摘要:nodejs 环境执行ts npm i @types/node --save-dev (node环境支持的依赖必装) npm i ts-node --g 例:运行water.ts文件 ts-node water.ts 阅读全文
posted @ 2022-11-21 20:01 泠风lj 阅读(938) 评论(0) 推荐(0) 编辑
摘要:1.找不到模块“../views/main.vue”或其相应的类型声明。 In the src folder add the file shims-vue.d.ts with the following content : Vue 2 : declare module "*.vue" { impor 阅读全文
posted @ 2021-11-10 17:34 泠风lj 阅读(103) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示