Javascript 为什么可以';我不能在react native中以编程方式添加道具吗?
使用本机导航器时 我使用的DisplayCustomSchema组件如下所示:Javascript 为什么可以';我不能在react native中以编程方式添加道具吗?,javascript,react-native,Javascript,React Native,使用本机导航器时 我使用的DisplayCustomSchema组件如下所示: this.props.navigator.push({ id: 'DisplayCustomSchema', name: 'DisplayCustomSchema', org:this.props.org }); 在DisplayCustomSchema组件componentDidMount中,我调用了一个ajax帖子并返回了一些数据 var DisplayCustomSchema =
this.props.navigator.push({
id: 'DisplayCustomSchema',
name: 'DisplayCustomSchema',
org:this.props.org
});
在DisplayCustomSchema组件componentDidMount中,我调用了一个ajax帖子并返回了一些数据
var DisplayCustomSchema = React.createClass({
componentDidMount : function(){
ajaxpost(data){ // example only
this.props.record=data
// I am trying to move the response data to props because I am using this data in my saveRecord function but it isn't showing up there.
}
}
render: function(){
<View>
<TouchableHighlight style={styles.touchButtonBorder} underlayColor="#ffa456" onPress={saveRecord.bind(this,this.props)}>
<Text style={styles.button}>SAVE</Text>
</TouchableHighlight>
</View>
}
})
var DisplayCustomSchema=React.createClass({
componentDidMount:function(){
ajaxpost(数据){//仅示例
this.props.record=数据
//我正在尝试将响应数据移动到props,因为我在saveRecord函数中使用了这些数据,但它没有显示在那里。
}
}
render:function(){
拯救
}
})
为什么数据没有分配给道具 @zvona是对的,
道具是只读的。不知道如何在reactjs中使用它,但你不应该这样写道具。如果需要这样做,请使用state
。props
是只读的。但是在reactjs中它是有效的。但是为什么ti不适用于react native呢