【问题标题】:Tags-based filtering with React Native使用 React Native 进行基于标签的过滤
【发布时间】:2018-04-13 12:51:56
【问题描述】:

这是我的问题。

当我按下 2 个按钮时,我希望这两个按钮的值变成 2 个“标签”,用于使用 React Native 从 mysql 数据库中过滤和获取我的数据。 我应该使用<Button><TouchableOpacity><TouchableHighlight> 或其他任何方法使其工作吗?

我将如何实现这一点?我需要一个示例代码。谢谢!

【问题讨论】:

    标签: javascript mysql react-native filter tags


    【解决方案1】:

    所有三个组件(ButtonTouchableOpacityTouchableHighlight)都可以用于此。它们都有onPress 属性,可以在用户按下交互时触发功能。使用哪一个主要是您对设计和实现的偏好。

    示例

    _onPress = (value) => {
      console.log(value); // Do something with the value
    }
    
    render() {
      return (
        <View>
          <Button onPress={() => this._onPress('Some Button Value')} title="Press Me!" />
          <TouchableOpacity onPress={() => this._onPress('Some TouchableOpacity Value')}>
            <Text>{'Press Me!'}</Text>
          </TouchableOpacity>
          <TouchableHighlight onPress={() => this._onPress('Some TouchableHighlight Value')}>
            <Text>{'Press Me!'}</Text>
          </TouchableHighlight>    
        </View>
      )
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-17
      • 2022-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-23
      相关资源
      最近更新 更多