私はネイティブの反応を学ぼうとしています。反応するネイティブフレックス50%エラーの原因
私は次のコードを持っている:私はこのコードを実行すると
<View>
<View style={{flex:0.5,flexDirection="row"}}>
<Image source={{uri:"http://image.com/image1.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 1</Text>
</View>
<View style={{flex:0.5,flexDirection="row"}}>
<Image source={{uri:"http://image.com/image2.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 2</Text>
</View>
<View style={{flex:0.5,flexDirection="row"}}>
<Image source={{uri:"http://image.com/image3.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 3</Text>
</View>
<View style={{flex:0.5,flexDirection="row"}}>
<Image source={{uri:"http://image.com/image4.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 4</Text>
</View>
</View>
しかし、これを、私はライン
<View style={{flex:0.5, flexDirection:"row"}}>
は「が予期しないトークンです」というエラーを取得します。
私は0.5を50%と "0.5"に置き換えようとしましたが、それらもエラーを引き起こします。これは、Web用のHTML、CSSた場合
は基本的に、私が達成しようとしている行動は次のとおりです。言い換えれば
<div>
<div style="width:50%; float:left;">
<img src="http://image.com/image1.jpg" style="width:100%; height:auto;" />
<span>Picture 1</span>
</div>
<div style="width:50%; float:left;">
<img src="http://image.com/image2.jpg" style="width:100%; height:auto;" />
<span>Picture 1</span>
</div>
<div style="width:50%; float:left;">
<img src="http://image.com/image3.jpg" style="width:100%; height:auto;" />
<span>Picture 1</span>
</div>
<div style="width:50%; float:left;">
<img src="http://image.com/image4.jpg" style="width:100%; height:auto;" />
<span>Picture 1</span>
</div>
</div>
、私はちょうど、各画像の下にキャプションをサムネイル画像の2つの列をしたいです。
しかし、 'flex:0.5'は' 50% 'を意味するものではなく、幅を設定しません。つまり、0.5の2を意味します。ここで、2は4項目の合計フレックス値から得られ、アイテム。あなたが探しているように見えるのは、 'flex-basis'です。RNにはありませんが、代用品はここにあります:https://stackoverflow.com/questions/35436478/react-native-substitute-for-flex-basis/43022365 – LGSon
上記の修正、ここでflexはRNで少し違っていて、_...左の**スペースをどのように分散すべきかを設定するのではなく、むしろ_...スペースをどのように分散すべきかを設定する_ – LGSon