React原生路由器flux:覆盖组件内部的左键或右键,并访问本地功能
react native router flux: override left or right button inside component and access local function
我能够覆盖组件内的按钮,但不能调用本地函数,例如,当我按下"Refresh"时,什么也没有发生。这是重写按钮文本并执行功能的正确方法吗?谢谢你的帮助。谢谢。
import { WebView } from 'react-native'
import React, { PropTypes, Component } from 'react';
import { View, Text } from 'react-native';
import styles from '../src/styles/home'
var WEBVIEW_REF = 'webview';
class WebViewComponent extends Component {
static rightTitle = "Refresh";
static onRight() {
this.reload;
}
static propTypes = {
url: PropTypes.string,
scalesPageToFit: PropTypes.bool,
startInLoadingState: PropTypes.bool,
};
static defaultProps = {
url: 'http://google.com',
scalesPageToFit: true,
startInLoadingState: true,
};
render() {
return (
<WebView
ref={ WEBVIEW_REF }
style={ { flex: 1, marginTop: 50 } }
source={ { uri: this.props.url } }
scalesPageToFit={ this.props.scalesPageToFit }
startInLoadingState={ this.props.startInLoadingState } />
);
}
reload = () => {
alert('reload');
};
}
module.exports = WebViewComponent;
经过一番研究,我得到了答案,不要使用静态,使用componentDidMount()
import { WebView } from 'react-native'
import React, { PropTypes, Component } from 'react';
import { View, Text } from 'react-native';
import styles from '../src/styles/home'
var WEBVIEW_REF = 'webview';
class WebViewComponent extends Component {
//here is the answer
componentDidMount() {
Actions.refresh({rightTitle: 'Refresh', onRight: this.reload})
}
static propTypes = {
url: PropTypes.string,
scalesPageToFit: PropTypes.bool,
startInLoadingState: PropTypes.bool,
};
static defaultProps = {
url: 'http://google.com',
scalesPageToFit: true,
startInLoadingState: true,
};
render() {
return (
<WebView
ref={ WEBVIEW_REF }
style={ { flex: 1, marginTop: 50 } }
source={ { uri: this.props.url } }
scalesPageToFit={ this.props.scalesPageToFit }
startInLoadingState={ this.props.startInLoadingState } />
);
}
reload = () => {
alert('reload');
};
}
module.exports = WebViewComponent;
相关文章:
- 点击(右键点击)使用传单地图库获取图像覆盖的像素坐标
- 何时可以;我的用户脚本在Javascript中触发右键单击(上下文菜单)
- 如何知道你右键点击谷歌chrome扩展是什么
- 我们可以在HTML中禁用右键单击锚标记吗
- 在动态crm 2011中,右键单击已完成活动的只读文本时,您是否出现错误
- jqGrid - 在右键单击时禁止选择行
- 右键单击夜巡
- JavaScript 左键和右键单击功能
- 如何禁用右键单击以在 JavaScript 中下载图像
- 如何禁用右键单击WordPress网站
- 导致右键单击触发左键单击
- 通过右键单击更改完整日历中事件的背景颜色 - 不起作用
- 在 CkEditor 4.3 中禁用右键单击
- 右键点击标记-谷歌地图V3
- 如何在右键单击链接并从上下文菜单访问功能后获取链接的 DOM
- Kiosk,没有键盘,需要访问右键点击事件
- 是否可以使用浏览器中的字符键生成右键单击事件以访问上下文菜单
- React原生路由器flux:覆盖组件内部的左键或右键,并访问本地功能
- 使用three.js访问右键
- 在网页上禁用右键是否会影响残疾人的可访问性?