import {createElement, Component} from 'weex-rx';
import {View, Text, TouchableHighlight} from 'nuke';
class myComponent extends Component {
render(){
return (
<TouchableHighlight onPress={()=>{
console.log('press');
}}>
<View>Test</View>
</TouchableHighlight>
);
}
}
除了Button等特殊组件外,其他的组件都支持onlongpress事件,如:
import { createElement, Component } from 'weex-rx';
import { mount } from 'nuke-mounter';
import { View, Text, Button, Modal} from 'nuke';
class Demo extends Component {
render() {
return (
<View
style={{flex:1,backgroundColor:'navy'}}
onlongpress={()=>{Modal.alert('onlongpress')}}>
</View>
);
}
}
mount(<Demo />, 'body');
export default Demo;
ListView的renderRow方法根节点的组件拥有ondisappear和onappear事件。
...
renderItem(item, index) {
return (
<TouchableHighlight ondisappear={()=>{Modal.alert('ondisappear')}}
onappear={()=>{Modal.alert('onappear')}} style={flex:1} >
<Text style={app.itemTextList}>{item.title}</Text>
</TouchableHighlight>
);
}
...
render() {
var self = this;
return (
<ListView
header={listHeader}
fixHeader={false}
loadMoreOffset="500"
style={app.listContainer}
refresh={listRefresh}
onloading={self.onloading}
onrefresh={self.onrefresh}
renderSeparator={self.separate.bind(self)}
renderRow={self.renderItem.bind(self)}
data={self.state.data}
stop={self.state.stop}
loadMore={self.handleLoadMore.bind(self)}
/>
)
}