【发布时间】:2016-01-24 03:56:04
【问题描述】:
我想知道是否可以在不使用导航器的情况下传递属性?我想要做的是将道具传递给位于我的 index.ios.js 中的 webview。
基本上,我的 index.ios.js 中有一个不可见的 iframe,它允许歌曲在整个应用程序中播放,尽管视图发生了变化,但我需要在按下按钮时更新 WebView 的源代码。
我的 index.ios.js 看起来像这样:
class queueThat extends React.Component {
constructor(props) {
super(props);
this.state = {
source: ''
};
}
render() {
return (
<View style={styles.container}>
<View style={styles.iframe}>
<WebView html={this.props.source} />
</View>
<React.NavigatorIOS
style={styles.container}
initialRoute={{
title: 'queueThat',
component: SearchPage,
}}/>
</View>
);
}
}
我的搜索结果页面按下功能如下:
rowPressed(rowID) {
this.setState({source: '<iframe width="100%" height="0" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' + this.props.collection[rowID].id + '&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>'})
console.log(this.state.source)
this.props.navigator.push({
passProps: {source: this.state.source}
})
}
我正在尝试将源代码传递给位于我的 index.ios.js 中的 WebView html,而不离开当前视图。
PS - 我对 JS 和 React 很陌生。
【问题讨论】:
标签: javascript ios reactjs react-native