项目选型
Vue3 + TSX
去掉 Tempate
模板的性能优化:静态提升、修补标记、树结构打平、加速SSR激活
如何做技术选型
- 要好招聘:提高程序员可替代性
- 要好用:自己用过或身边人用过,反馈不错
- 要有长期维护者:付费维护者 > 免费维护者 > 兼职维护者
- 无利益冲突:预防技术或经济制裁封锁,寻找可替代性
- 占有率:满足规模即可,大公司不能保证长久。(林迪效应)
Ruby
class User
def initialize(name)
# 类似this
@name = name
end
def hi(target)
print "Hi #{target}, I am #{@name}"
end
end
u1 = User.new 'Aziz'
u1.hi 'jack'
# Hi jack, I am Aziz
JS高级函数
// 单行函数
const (a,b) => (console.log('hi'), a+b)
多行函数
const f =
a => b => a +b
f(1)(2)
// 3
const f2 = fn => fn(1,2)
f2( (a,b)=>a+b )
// 3
扩展操作符
const user = {name:'Aziz', age:18}
const user2 = {...user, name:'Jack'}
const user3 = Object.assign({}, user, {name:'Jack'})
const call = (fn, ...args) => fn(...args)
call( (a,b)=> a+b, 1, 2)
TS代码
// 类型声明
type Cat = 'Cat'
// 声明对象/函数
interface User {
readonly id : string
name : string
age? : number
}
// 泛型+继承
interface UserWithPet<T> extends User {
pet : T
}
// 声明
const user : UserWithPet<Cat> = {
id : '123',
name : 'Aziz',
pet : 'Cat'
}