下面这种试过不行!
//index.js
constructor(props, context) {
super(props, context)
this.context = {
modelname: 'apiConfigurationModel',
}
}
getChildContext() {
return this.context
}
为了在父级组件使用和子组件同一个context
下面这种试过不行!
//index.js
constructor(props, context) {
super(props, context)
this.context = {
modelname: 'apiConfigurationModel',
}
}
getChildContext() {
return this.context
}
为了在父级组件使用和子组件同一个context
4 回答1.7k 阅读
2 回答1.1k 阅读✓ 已解决
2 回答2.6k 阅读
1 回答962 阅读✓ 已解决
1 回答689 阅读✓ 已解决
2 回答852 阅读✓ 已解决
2 回答1k 阅读
this.context
是用来读取这个component的父级components传下来的context值啊,你这样写会出bug的。。。加默认值嘛,何必执着于一定要放在context里。。。
比如可以:
再如: