修改端口号:node_modules\react-native\local-cli\server\server.jsnode
生成apk:react-native run-android --variant=releasereact
编译项目:react-native startandroid
base:{width:38,height:38},react-native
background:{backgroundColor:’#222’},数组
active:{borderWidth:2,borderColor:#ccc},网络
})antd
定义多个样式:<View style={[styles.base,styles.background]}/>async
在两个样式里面内容有冲突的时候,以右边的值优先,还能够加判断此样式在什么条件下会显示:<View style={[styles.base,this.state.active&&styles.active]}函数
&&左边是true/false 右边是样式fetch
<Procedure info={info} key={index}></Procedure>
))}
Procedure为将要循环的数组
A页面写:componentDidMount() {
this.listener = DeviceEventEmitter.addListener('Updata',(e)=>{
alert(e)
这里写须要更新的函数
});
}
componentWillUnmount(){
this.listener.remove();
}
B页面写:DeviceEventEmitter.emit('Updata');
a) justifyContent:'flex-start', // 左对齐,默认值
b) justifyContent:'flex-end', // 右对齐
c) justifyContent:'center', // 居中
d) justifyContent:'space-between', // 两端对齐,项目之间间隔相等
e) justifyContent:'space-around', // 每一个项目两端的间隔相等。因此项目间的间隔比项目与边框的间隔大一倍
f) alignItems:'flex-start', // 交叉轴起点对齐
g) alignItems:'flex-end', // 交叉轴终点对齐
h) alignItems:'center', // 交叉轴中点对齐
i) alignItems:'baseline', // 项目第一行文字的基线对齐
j) alignItems:'stretch', // 若是项目未设置高度或设为auto,将占满整个容器的高度
underlineColorAndroid='transparent' 去掉下划线
例:<ScanList info={info} key={index+""+this.state.showPop} show={this.state.showPop} navigation={this.props.navigation}/>
a) 打开扫描:LeZhanTools.openScan(); LeZhanTools.Vibrate(1);
b) 关闭扫描:LeZhanTools.closeScan();
c) 读取扫描出来的信息:DeviceEventEmitter.addListener('ScanCode', function(e: Event) {
d) alert(JSON.stringify(e)+"222222222")
e) });
BackHandler在上面引入。from 'react-native'
componentDidMount() {
this.listenerhardwareBackPress=BackHandler.addEventListener('hardwareBackPress', ()=> {
this.backClick();
return true;
});
}
子组件:back(){ this.props.back()}
修改以下:
......
......
export default function<S: {}>(
navigation: NavigationProp<S>
): NavigationScreenProp<S> {
/* ------------此处为添加的代码--------- */
let debounce = true;// 定义判断变量
/* ------------此处为添加的代码--------- */
return {
...navigation,
goBack: (key?: ?string): boolean => {
let actualizedKey: ?string = key;
if (key === undefined && navigation.state.key) {
invariant(
typeof navigation.state.key === 'string',
'key should be a string'
);
actualizedKey = navigation.state.key;
}
return navigation.dispatch(
NavigationActions.back({ key: actualizedKey })
);
},
navigate: (
routeName: string,
params?: NavigationParams,
action?: NavigationNavigateAction
/* ------------此处为修改后的的代码--------- */
): boolean =>{
if (debounce) {
debounce = false;
navigation.dispatch(
NavigationActions.navigate({
routeName,
params,
action,
}),
);
setTimeout(
() => {
debounce = true;
},
5000,
);
return true;
}
return false;
},
/* ------------此处为修改后的的代码--------- */
......
},{
transitionConfig: horizontalInterpolator
})
上面定义:const horizontalInterpolator = () => ({screenInterpolator: CardStackStyleInterpolator.forHorizontal})
import CardStackStyleInterpolator from 'react-navigation/src/views/CardStack/CardStackStyleInterpolator';
{this.state.inner1Con ? (this.state.inner1Con.length > 7 ? this.state.inner1Con.substr(0, 7) + "..." : this.state.inner1Con) : "请选择"}
<View style={styles.lineDashed}></View>
lineDashed:{
width:width,
height:0,
borderWidth:1,
borderColor:'#ccc',
borderStyle:'dashed',
borderRadius:0.1,
},
import { Switch,SwipeAction } from 'antd-mobile-rn';
const right = [{
text: '删除',
onPress: () => alert('delete'),
style: { backgroundColor: 'red', color: 'white' },
},];
<SwipeAction autoClose right={right}>
<Text>这行左滑删除</Text>
</SwipeAction>
import { NetInfo } from 'react-native';
//检测网络是否链接
NetInfo.isConnected.fetch().done((isConnected) => {
alert(isConnected + '==检测网络是否链接')
});
//检测网络链接信息
NetInfo.fetch().done((connectionInfo) => {
alert(connectionInfo + '==检测网络链接信息')
});
//监听网络变化事件
NetInfo.addEventListener('change', (networkType) => {
alert(networkType + '==监听网络变化事件')
})
ANT UI