Javascript 将参数传递给根组件
您可以在react native中将参数(如初始道具)传递给根组件吗 例如 我得到一个错误: 无法执行JS调用:fbBatchedBridge未定义Javascript 将参数传递给根组件,javascript,react-native,react-native-android,react-native-ios,Javascript,React Native,React Native Android,React Native Ios,您可以在react native中将参数(如初始道具)传递给根组件吗 例如 我得到一个错误: 无法执行JS调用:fbBatchedBridge未定义 由于Volcalc是您的根组件,只需在该方法的构造函数中指定组件属性: class Volcalc extends React.Component { constructor(props) { super(props); this.state = { height: 10,
由于
Volcalc
是您的根组件,只需在该方法的构造函数中指定组件属性:
class Volcalc extends React.Component {
constructor(props) {
super(props);
this.state = {
height: 10,
width: 10,
...
}
...
}
...
如果您希望根据平台(iOS和Android)的不同而有不同的高度,那么在index.Android.js
和index.iOS.js
中创建一个根组件,在其中呈现Volcalc
组件:
class Volcalc extends React.Component {
constructor(props) {
super(props);
this.state = {
height: 10,
width: 10,
...
}
...
}
...