location.href 跳转失败
使用 location.href 进行页面链接跳转失败
解决:
window.location.href = urls[index].url;
// 直接立即 reload 跳转失败
// window.location.reload();
// location.href 为异步操作,需要 settimeout 后再重新加载
setTimeout(() => {
window.location.reload()
}, 100)
TS typeof && keyof
typeof
const x = {
name: 'xxx',
age: 22,
job: 'FE'
}
type TTypeOf = typeof x;
// type TTypeOf = {
// name: string;
// age: number;
// job: string;
// }
keyof
type TKeyOf = keyof TTypeOf;
// type TKeyOf = "name" | "age" | "job"