无障碍
字号适应
要求:全站不可使用 px 值font-size,若需布局适应,所有 px 值改为 em 值。
浏览器提供了字号设置,用于照顾视觉障碍人士的内容查看,但需要网页本身采用 em 或 rem 来进行 font-size 的设置,且如果某处 标签(如 html/body)设置了具体 px 值的 font-size,该特性仍会失效。
https://flow.org/en/docs/lang/variance/
特大
中
不设置font-size html会自己设具体 px 值:
如特大会设置 24px,中(推荐)则是 16px
CSS
行距
行高值为一个数字时
行高 = 行高值 * font-size
行距 = 行高 - font-size
所以文字行真实高应为行距 + font-size
半行距若为小数,上半行距向下取整,下边距向下取整,因为大多数字体内容偏下。
Typescript
as
as 断言是一种危险的操作,用直白的话来描述就是:
元首(你)对总理(Ts 编译器)说:A(某变量)从今天起就是党内人士,后面的兄弟不用纠结他的成分了。
某次党内会议(真实执行环境),A携带的公文包里放着炸药,炸死了元首(系统崩溃)。
总理的眼力还是挺好的,元首的疏忽往往能提前预判:
但假若总理光拿到了身份证明,忘记调查某特务的家族背景,悲剧往往会发生:
as 断言需要元首有自行承担风险及提前认知风险的能力,如若不,还是把事情交给总理来代劳(: 声明类型)较为合适。
Type
子类型关系与继承
https://www.zhihu.com/question/57486254
subtype 子类型
supertype 超类型 父类型
subtyping 子类型关系,注重的是建立一种”is a”的关系,同时它的本质是与另一类型建立substitutability。或 compatibility。当A <: B, 所有B的值都可被A的值替换 ,所有B的位置对于A来说都是compatible的。
subtyping是compatibility of interfaces,inheritance是reuse of implementations
**
In a number of object-oriented languages, subtyping is called interface inheritance, with inheritance referred to as implementation inheritance. 在很多OO语言中,subtyping被称作接口继承,而inheritance则被称为实现继承。
subtyping是一种在semantics上定义的关系。也就是说说而已的意思?
所以谈 subtyping 关系时只是在谈抽象类型,谈 inheritance 时则是在谈已经做的真实实现。
interface & type alias & class
the key distinction is that a type cannot be re-opened to add new properties vs an interface which is always extendable.
https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces