修改端口號: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