XSXin sheninlihua.hashnode.dev·Nov 30, 2022 · 1 min readRails add foreign keywhen we want to add a foreign key in Rails we can run this command bin/rails g migration add_author_to_books author:references this means one author has one or more books in the database class AddAuthorToBooks < ActiveRecord::Migration[7.0] def ch...00
XSXin sheninlihua.hashnode.dev·Apr 22, 2022 · 1 min read测试 React 应用使用 create-react-app 除了 Jest 之外,我们还需要另一个测试库,它将帮助我们以测试目的渲染组件。 目前最好的选择是react-testing-library ,这个库在最近几年迅速流行起来。 npm install --save-dev @testing-library/react @testing-library/jest-dom 依赖项 "dependencies": { "@testing-library/jest-dom": "^5.14.1", ...00
XSXin sheninlihua.hashnode.dev·Apr 22, 2022 · 1 min readtype 和 interface 的区别是什么?组合方式: interface 使用extends来实现继承,type 使用&来实现联合类型。 扩展方式: interface 可以重复声明用来扩展,type 一个类型只能声明一次 范围不同: type 适用于基本类型,interface 一般不行。 命名方式: interface 会创建新的类型名,type 只是创建类型别名,并没有新创建类型。00
XSXin sheninlihua.hashnode.dev·Apr 22, 2022 · 1 min readGit中只merge部分commitcherry-pick 在Git 1.7.2以上的版本引入了一个 cheery-pick的命令可以只merge 部分的commit而不用直接把整个分支merge过来 git cherry-pick <commit 号> 如: git cherry-pick e43a6fd3e94888d76779ad79fb568ed180e5fcdf 这样就只会把这个e43a6fd3e94888d76779ad79fb568ed180e5fcdf commit的内容pull到当前的分支,不过你会得到一个新的c...00
XSXin sheninlihua.hashnode.dev·Apr 18, 2022 · 1 min readTypeScriptType声明基本类型 声明字符串类型 type Name = string const str:Name= 'bot 声明 字符串或数字类型 type Id = string|number const id1:Id = '123' const id2:Id = 123 同时满足两种类型类型为never(写错了可能) type wrongType = string & number 可选类型 type User = { name:string age?:number } c...00