1.meta http-equiv 设置请求头问题
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
这是一套存在于HTML4时期的,前端在html里面直接修改请求头参数,执行缓存策略为不缓存。不过这套东西已经失效,HTML5对meta内的http-equiv进行了设置,只能使用数种固定策略,不能直接设置请求头
2.React props传递问题
下面这种写法会弹出callback,isGet不合法的警告
// ParentA
function callBack() {
}
render() {
let isGet = true
return <ChildB callBack={() => {this.callBack}} isGet={isGet} />
}
//ChildB
render() {
return <ChildC {...this.Props}/>
}
原因在于ChildB将父类ParentA传递下来的自定义属性直接,通过props的形式直接传递到了ChildC中,react不推荐这种传递方式,会让人很困惑ChildC接收了哪些属性,不需要传递的属性,我们要跑出来,需要传递的自定义属性需要单独传递,系统属性可以通过props直接传递下去
//ChildB
render() {
const {callBack,isGet,...other} = this.props
return <ChildC callBack={callBack} {...other} /> //不传递isGet,非自定义内容直接通过other传递
}