react-native的公共代码和插件

1.加密crypto-js

安装:npm install crypto-js --save

//DES加密
encryptByDES(message,key) {

    var CryptoJS= require("crypto-js");

    var keyHex= CryptoJS.enc.Utf8.parse(key);

    var encrypted= CryptoJS.DES.encrypt(message, keyHex, {

    mode: CryptoJS.mode.ECB,

    padding: CryptoJS.pad.Pkcs7

  });

  return encrypted.toString();

}
//转码并且传参(parameter是要加密的内容,'DES_KEY'是加密的密码)
encodeURIComponent(this.encryptByDES(parameter,'DES_KEY'));

2.自定义页面返回样式

 static navigationOptions = ({navigation}) => ({
    headerTitle: ("返回"),
    tabBarVisible: false,
    headerLeft:(
        
    )
 })
 componentDidMount () {
    this.props.navigation.setParams({navigatePressBack:this.goBack});
 }
 goBack = () => {
    const { goBack,navigate } = this.props.navigation
    goBack ()
 }

你可能感兴趣的:(react-native的公共代码和插件)