Vya*_*ddy 3 javascript react-native native-base
我在执行 forceRtl 时遇到了本机基本选项卡的问题。一切正常,但只有 native base 在初始加载时不显示任何内容。
所以我有一个临时解决方案
在 native-base/src/basic/Tabs/index.js
import { I18nManager } from "react-native"
renderScrollableContent() {
const scenes = this._composeScenes();
const isRTLAndroid = I18nManager.isRTL;
return (
<ScrollView
horizontal
pagingEnabled
automaticallyAdjustContentInsets={false}
keyboardShouldPersistTaps="handled"
contentOffset={{
x: this.props.initialPage * this.state.containerWidth
}}
ref={scrollView => {
this.scrollView = scrollView;
}}
onScroll={e => {
const offsetX = e.nativeEvent.contentOffset.x;
this._updateScrollValue(offsetX / this.state.containerWidth);
}}
onMomentumScrollBegin={this._onMomentumScrollBeginAndEnd}
onMomentumScrollEnd={this._onMomentumScrollBeginAndEnd}
scrollEventThrottle={16}
scrollsToTop={false}
showsHorizontalScrollIndicator={false}
scrollEnabled={!this.props.locked}
directionalLockEnabled
alwaysBounceVertical={false}
keyboardDismissMode="on-drag"
{...this.props.contentProps}
>
/*******************************************
If is isRtl do reverse else keep as it is
********************************************/
{isRTLAndroid?scenes.reverse():scenes}
</ScrollView>
);
},
Run Code Online (Sandbox Code Playgroud)
不要忘记更改 package.json 中的 "main": "src/index.js"