react+Native使用typeScript
1、為什么使用typeScript?
typeScript是JavaScript的超集
typeScript在編譯期間就可以將錯(cuò)誤拋出
增強(qiáng)代碼的可閱讀性和可維護(hù)性
2、案例的功能邏輯
切換職業(yè)
選擇服務(wù)區(qū)域
選擇服務(wù)品種
選擇服務(wù)承諾
3、使用命令創(chuàng)建react Native的typescript
詳情參考react Native中文官網(wǎng)https://reactnative.cn/docs/typescript#__docusaurus
react-native init MyAwesomeProject --template typescript
4、使用第三方庫(kù)和聲明文件
yarn add react-native-modal yarn add react-native-vector-icons
yarn add --dev @types/react-native-vector-icons
5、使用樣式
import {StyleSheet} from ''react-native;
const style = StyleSheet.create({
container:{
flexDirection:;'row';
}
})
6、使用圖標(biāo)
import Icon from "react-native-vector-icons/FontAwesome";
<Icon name='check' size={12}/>
react-native link react-native-vector-icons
PureComponent通過(guò)prop和state的淺比較來(lái)實(shí)現(xiàn)shouldComponentUpdate

浙公網(wǎng)安備 33010602011771號(hào)