用文本反应本机,图像滑块框

黑暗王子

我是本机的新用户,我已安装它,react-native-image-slider-box但我也希望当该图像的图像幻灯片标题也像用户幻灯片图像一样更改时,使该图像的标题也更改。我更改了react-native-image-slider-box程序包的代码,但无法正常工作。下面是该代码

 _renderItem({ item, index }) {
    const {
      ImageComponent,
      ImageComponentStyle = {},
      sliderBoxHeight,
      disableOnPress,
      resizeMethod,
      resizeMode,
      imageLoadingColor = "#E91E63"
    } = this.props;
    return (
      <View
        style={{
          position: "relative",
          justifyContent: "center"
        }}
      >
        <Text style={[style.fontSize30Semi, {marginRight: moderateScale(100)}]}>
          {this.props.title}
        </Text> //that's the code I added in react-native-image-slider-box
          <ImageComponent
            style={[
              {
                width: '100%',
                height: moderateScaleVertical(350),
                marginVertical: moderateScaleVertical(10),
              },
              ImageComponentStyle
            ]}
            source={typeof item === "string" ? { uri: item } : item}
            resizeMethod={resizeMethod || "resize"}
            resizeMode={resizeMode || "cover"}
            onLoad={() => {}}
            onLoadStart={() => {}}
            onLoadEnd={() => {
              let t = this.state.loading;
              t[index] = true;
              this.setState({ loading: t });
            }}
            {...this.props}
          />
        {!this.state.loading[index] && (
          <ActivityIndicator
            size="large"
            color={imageLoadingColor}
            style={{
              position: "absolute",
              alignSelf: "center"
            }}
          />
        )}
      </View>
    );
  }

Welcome.js

 state = {
    images: [imagePath.welcome1, imagePath.welcome2, imagePath.welcome3],
    desc: ['Hello', 'My'],
  };
  ...
  <SliderBox images={this.state.images} title={this.state.desc} />

那就是我的代码,我试图为不同的图像渲染不同的标题。谁能帮助我,告诉我该怎么做?

古拉帕兰·吉里塔兰(Guruparan Giritharan)

该库支持任何文本,您可以执行以下操作

 state = {
    images: [imagePath.welcome1, imagePath.welcome2, imagePath.welcome3],
    desc: ['Hello', 'My'],
    currentIndex:0
  };
  
      <Text>{this.state.desc[this.state.currentIndex]}</Text>
      <SliderBox images={this.state.images} title={this.state.desc} currentImageEmitter={i=>this.setState({currentIndex:i})}/>

currentImageEmitter将发送当前图像的索引,您可以使用它来更新状态并根据索引显示文本。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

用图像和文本反应本机FlatList问题

来自分类Dev

在多行文本旁边反应本机图像?

来自分类Dev

用Alpha反应本机可点击图像

来自分类Dev

连续对齐多个文本框反应本机

来自分类Dev

Bootstrap 中滑块库中图像上的文本框

来自分类Dev

反应旋转木马/图像滑块

来自分类Dev

反应本机失败的上传图像

来自分类Dev

反应本机图像加载太慢

来自分类Dev

反应本机图像不显示

来自分类Dev

如何反应本机滚动文本?

来自分类Dev

反应本机Flatlist文本更改

来自分类Dev

如何反应本机滚动文本?

来自分类Dev

用列反应本机SectionList

来自分类Dev

用圆角反应渐变滑块(评级组件)

来自分类Dev

添加反应本机矢量图标以用反应本机Web反应本机时出错

来自分类Dev

反应本机明文多个TextInput框

来自分类Dev

反应本机弹性框拆分屏幕

来自分类Dev

使用超链接反应本机iOS图像

来自分类Dev

需要反应本机0.14.2中的图像

来自分类Dev

反应本机,无法解析模块的静态图像

来自分类Dev

反应本机相对图像路径加载

来自分类Dev

反应本机相对图像路径加载

来自分类Dev

将本机图像 url 反应为参数

来自分类Dev

无法在本机反应中共享图像

来自分类Dev

使用行数反应本机文本组件

来自分类Dev

Bootstrap滑块范围值文本框

来自分类Dev

对文本而不是图像使用jQuery滑块?

来自分类Dev

滑块不显示图像,但显示纯文本

来自分类Dev

Jekyll - 在滑块中显示图像和文本