ts

前端命令——编译文件ts scss sass 等

## 1. 安装 ```bash npm install -g typescript ``` ```bash tsc --initÏ ``` ## 2. 使用方法 ### 2.1、将ts文件转化为js ```bash tsc index.ts ``` 会自动生成对应的index.js文件 ### 2 ......
前端 命令 文件 scss sass

【算法】在vue3的ts代码中分组group聚合源数据列表

有一个IList<any>()对象列表, 示例数据为[{id:'1',fieldName:'field1',value:'1'},{id:'1',fieldName:'field2',value:'2'},{id:'2',fieldName:'field1',value:'1'},{id:'2',f ......
算法 代码 数据 group vue3

typeScript学习-TS类型-其他特殊类型-可变元组

typeScript学习 可变元组: let people: [string, number, string, string, string] = ["wangwu", 23, "地址", '13312341234', '备注'] // 当前三个数据固定格式,后面数据不确认格式时 用可变元组 // ......
类型 typeScript TS

typeScript学习-TS类型-对象类型-Array

typeScript学习 对象类型-Array 数组和数组元素只读 const account = [10, 40, 50, 60, 90] as const // account[0] = 100 // 错误 export { } ......
类型 typeScript 对象 Array TS

typeScript学习-TS类型-其他特殊类型-元组(tuple)

typeScript学习 元组(tuple): 满足以下3点的数组就是元组 (1)在定义时每个元素的类型都是确定 (2)元素值的数据类型必须是当前元素定义的类型 (3)元素值的个数必须和定义时个数相同 let salary: [string, number, number, number, numb ......
类型 typeScript tuple TS

vue3+vite+ts项目初始化

### 创建项目 ``` # npm 6.x npm create vite@latest my-vue-app --template vue # npm 7+, extra double-dash is needed: npm create vite@latest my-vue-app -- -- ......
项目 vue3 vite vue ts

vue3+ts绘制二维码

界面展示 实现步骤 引入qrcode.vue npm i qrcode.vue 界面引入并使用 <template> <div> <el-row>二维码标签</el-row> <el-row :gutter="20"> <el-col :span="6"> <el-input v-model="co ......
vue3 vue ts

ts中this的处理

ts函数中,直接使用this会报错: "this" 隐式具有类型 "any",因为它没有类型注释。 应该以参数形式声明this,以防抖函数为例 function debounce(fn: Function, time: number) { let timer: number return funct ......
this

typeScript学习-TS类型-null和undefined

typeScript学习 null 和 undefined undefined any unknown 可以接受 undefined let data: undefined = undefined let data2: any = undefined let data3: unknown = und ......
typeScript undefined 类型 null TS

typeScript学习-TS类型-合成类型

typeScript学习 合成类型:联合类型, 交叉类型 联合类型: let str:srting | number = "abc" str=3 交叉类型: type Obj1 = {username:string} type Obj2 = {age:number} let obj:Obj1={us ......
类型 typeScript TS

typeScript学习-TS类型-字面量数据类型

typeScript学习 字面量数据类型: // type A = number | string // let a:A = "abc" // type num = number // let n:num = 3 type num = 1 | 2 | 3 let n:num = 2 // 错误情况 ......
类型 字面 typeScript 数据 TS

typeScript学习-TS类型-其他特殊类型-never

typeScript学习 其他特殊类型: any, unknown, never, void, 元组(tuple), 可变元组 never: // dataFlowAnalysisWithNever 方法穷尽了 DataFlow 的所有可能类型。 // 使用 never 避免出现未来扩展新的类没有对 ......
类型 typeScript never TS

typeScript学习-TS类型-其他特殊类型-any、unknown

typeScript学习 其他特殊类型: any, unknown, never, void, 元组(tuple), 可变元组 any 比较经典的应用场景: 1、自定义守卫 2、需要进行 as any 类型断言的场景 unknown 一般用作函数参数: 用来接收任意类型的变量实参,但在函数内部只用于 ......
类型 typeScript unknown any TS

typeScript学习-TS类型-枚举

typeScript学习 枚举:enum 枚举的定义:用来存放一组固定的常量的序列。 枚举带来的好处: 1、有默认值和可以自增值,节省编码时间 2、语义更清晰,可读性增强, 因为枚举是一种值类型的数据类型,方法参数可以明确参数类型为枚举类型 enum WeekEnd { Monday = "myMo ......
typeScript 类型 TS

typeScript学习-TS类型-接口

typeScript学习 接口: 定义:另一种定义对象类型的类型 接口应用场景: 1、一些第三方包或者框架底层源码中有大量的接口类型 2、提供方法的对象类型的参数时使用 3、为多个同类别的类提供统一的方法和属性声明 如何定义接口: 继承接口: 新的接口只是在原来接口集成之上增加了一些属性或方法,这是 ......
typeScript 接口 类型 TS

TS函数重载

1.函数重载的目的 重载允许一个函数接受不同数量或类型的参数时,作出不同的处理。 2.重载的实现 允许一个函数接受不同数量或类型的参数 我们重复定义了多次函数 reverse,前几次都是函数定义,最后一次是函数实现。在编辑器的代码提示中,可以正确的看到前两个提示。 注意,TypeScript 会优先 ......
函数

typeScript学习-TS类型

typeScript学习 常用的24中 TS 类型 基本类型: number, string, boolean, symbol, null, undefined 根类型: Object, {} Object:除了 null 和 undefined,其他类型都可以赋值给 Object 类型,简写{}。 ......
typeScript 类型 TS

引入外部ts文件,修改外部ts参数

<template> <div class="home"> <div>调用外部js:{{addNum}}</div> <button @click="clickAdd">加</button> <div>改变外部js参数:{{count}}</div> <button @click="clickCha ......
参数 文件

uniapp+ts页面接收传参

<script setup lang="ts"> import { onLoad } from '@dcloudio/uni-app'; //接收传参 onLoad(options => { console.log(options ); }); </script> ......
页面 uniapp ts

ts执行文件报错

我重新安装了项目的 npm 包,执行 ts 文件报错: tsc src/index.ts node_modules/@types/node/globals.d.ts:72:13 - error TS2403: Subsequent variable declarations must have th ......
文件

如何为你的 js 项目添加 ts 支持?

前一段时间为公司内的一个 JS 公共库,增加了一些 TypeScript 类型支持。在这里简答记录一下。 ![](https://img2023.cnblogs.com/blog/3251068/202308/3251068-20230802202159901-258478020.png) ## 安 ......
项目 js ts

ts总结

> 原文地址 [juejin.cn](https://juejin.cn/post/7088304364078497800) 先来看看知识图,如果你对以下概念有盲区,那么这篇文章应该能很好的帮助到你~ ![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fb ......

vite+vue3+ts+elementPlus前端框架搭建 [二] pinia状态管理

前面已经完成了基本框架搭建,下一步针对各个模块的封装以及实验 本章主要是针对pinia的状态模块实现 1. 创建Store 在src文件夹下创建一个store的文件夹,并在该文件夹下创建index.ts文件,内容如下: import type { App } from 'vue'; import { ......
前端 elementPlus 框架 状态 pinia

vite+vue3+ts+elementPlus前端框架搭建 [一]

记录下搭建vite + vue3 + ts + elementPlus项目的过程及遇到的问题。 建议使用pnpm安装依赖,npm切换到pnpm 链接地址:[https://www.pnpm.cn/installation]() 1. 运行环境 node -v v18.17.0 npm -v 9.8. ......
前端 elementPlus 框架 vite vue3

ts中的泛型

在 TypeScript 中我们会使用泛型来对函数的相关类型进行约束 这里的函数 同时包含 class 的构造函数 因此 一个类的声明部分 也可以使用泛型 那么 什么是泛型? 如果通俗的理解泛型呐? ### 什么是泛型 **泛型 (Generics) 是指在定义函数 接口或类的时候 不预先指定具体的 ......

TS中的Type和Interface

> 学习内容来源于:https://www.youtube.com/watch?v=Idf0zh9f3qQ # Type 与 Interface的区别 1. 编写方式 ```ts type UserProps = { name: string; age: number; } interface Us ......
Interface Type

Angular:error TS2717: Subsequent property declarations must have the same type. Property 'contentRect' mu st be of type 'DOMRectReadOnly', but here has type 'DOMRectReadOnly'.

# 解决方案 在`tsconfig.json`的`compilerOptions`选项中添加如下内容`"skipLibCheck": true`。 如下图所示 ![image](https://img2023.cnblogs.com/blog/1795938/202307/1795938-20230 ......

uniapp+vue3+ts 使用pinia报错

"hasInjectionContext" is not exported by "node_modules/vue-demi/lib/index.mjs", imported by "node_modules/pinia/dist/pinia.mjs". 11:36:19.397 at ../no ......
uniapp pinia vue3 vue ts

Angular 应用里的 public_api.ts 文件的作用

在 Angular 应用中,`public_api.ts` 是一个常见的约定,用于定义库或模块的公共 API。这个文件导出了库或模块提供给外部使用的所有部分,例如组件、服务、接口、类型、函数等。当其他应用或库引用这个库时,它们只能访问在 `public_api.ts` 中导出的内容。 `public ......
public_api 作用 Angular 文件 public

vue3 TS vite element ali-oss使用方式

# vue3 TS vite element ali-oss使用方式 1. 安装ali-oss包 ```cmd npm i ali-oss -S ``` 2. 使用oss封装函数 ``` const OSS = require('ali-oss') // import Oss from 'ali-o ......
element ali-oss 方式 vue3 vite