# npx 是什么?
- 避免安装全局模块(例如只使用一次的脚手架等)
- 便于调用项目内部安装的模块,例如:
```shell
# node_modules/.bin/mocha --version
# npx mocha --version
```
# 用脚手架搭建环境
```
npx create-react-app projName --typescript
```
可以在 tsconfig 文件中配置 tsc 编译器
# 一个 tsx 组件结构
```js
import React from 'react'
// 用 interface 限制 props 属性,这样当使用时传入不正确的属性编译器会报错
interface IHelloProps {
message?: string;
}
const Hello: React.FC<IHelloProps> = (props) => { // React.FC 是 React.FunctionComponent 的别名,其是描述函数的 interface
return <h2>{props.message}</h2>
}
// 使用 React.FC 后可获得一系列静态属性
Hello.defaultProps = {
message: 'Hello World'
}
export default Hello
```
# 项目结构
```
proj/
README.md
node_modules/
package.json
tsconfig.json
src/
components/
Button/
button.tsx // 组件主体
button.test.tsx // 测试
style.scss // 样式
styles/
...
index.tsx
```
# Bug 记录
1、脚手架搭建后 npm 安装 node-sass 总是删除之前的包导致出错。(Win10)
解决方案:使用 yarn add 安装
```
yarn add node-sass
```
| npm | yarn |
| --- | --- |
| npm install | yarn |
| npm install react --save | yarn add react |
| npm uninstall react --save | yarn remove react |
| npm install react --save-dev | yarn add react --dev |
| npm update --save | yarn upgrade |
# 常用第三方库
1、node-sass
```markup
yarn add node-sass
```
2、classnames
```shell
yarn add classnames
yarn add @types/clasnames
or
npm install classnames --save
npm install @types/classnames --save
```
- 序言 & 更新日志
- H5
- Canvas
- 序言
- Part1-直线、矩形、多边形
- Part2-曲线图形
- Part3-线条操作
- Part4-文本操作
- Part5-图像操作
- Part6-变形操作
- Part7-像素操作
- Part8-渐变与阴影
- Part9-路径与状态
- Part10-物理动画
- Part11-边界检测
- Part12-碰撞检测
- Part13-用户交互
- Part14-高级动画
- CSS
- SCSS
- codePen
- 速查表
- 面试题
- 《CSS Secrets》
- SVG
- 移动端适配
- 滤镜(filter)的使用
- JS
- 基础概念
- 作用域、作用域链、闭包
- this
- 原型与继承
- 数组、字符串、Map、Set方法整理
- 垃圾回收机制
- DOM
- BOM
- 事件循环
- 严格模式
- 正则表达式
- ES6部分
- 设计模式
- AJAX
- 模块化
- 读冴羽博客笔记
- 第一部分总结-深入JS系列
- 第二部分总结-专题系列
- 第三部分总结-ES6系列
- 网络请求中的数据类型
- 事件
- 表单
- 函数式编程
- Tips
- JS-Coding
- Framework
- Vue
- 书写规范
- 基础
- vue-router & vuex
- 深入浅出 Vue
- 响应式原理及其他
- new Vue 发生了什么
- 组件化
- 编译流程
- Vue Router
- Vuex
- 前端路由的简单实现
- React
- 基础
- 书写规范
- Redux & react-router
- immutable.js
- CSS 管理
- React 16新特性-Fiber 与 Hook
- 《深入浅出React和Redux》笔记
- 前半部分
- 后半部分
- react-transition-group
- Vue 与 React 的对比
- 工程化与架构
- Hybird
- React Native
- 新手上路
- 内置组件
- 常用插件
- 问题记录
- Echarts
- 基础
- Electron
- 序言
- 配置 Electron 开发环境 & 基础概念
- React + TypeScript 仿 Antd
- TypeScript 基础
- React + ts
- 样式设计
- 组件测试
- 图标解决方案
- Storybook 的使用
- Input 组件
- 在线 mock server
- 打包与发布
- Algorithm
- 排序算法及常见问题
- 剑指 offer
- 动态规划
- DataStruct
- 概述
- 树
- 链表
- Network
- Performance
- Webpack
- PWA
- Browser
- Safety
- 微信小程序
- mpvue 课程实战记录
- 服务器
- 操作系统基础知识
- Linux
- Nginx
- redis
- node.js
- 基础及原生模块
- express框架
- node.js操作数据库
- 《深入浅出 node.js》笔记
- 前半部分
- 后半部分
- 数据库
- SQL
- 面试题收集
- 智力题
- 面试题精选1
- 面试题精选2
- 问答篇
- 2025面试题收集
- Other
- markdown 书写
- Git
- LaTex 常用命令
- Bugs