将按钮或TouchableHighlight嵌套在TouchableHighlight中

时间:2019-11-03 03:17:11

标签: react-native button

我有一个使用public class Game { public string GameId { get; set; } public string GenreId { get; set; } } var list = new List<Game>{ new Game { GameId = "Final Fantasy VII", GenreId = "RPG" }, new Game { GameId = "Dark Souls", GenreId = "RPG" }, new Game { GameId = "Dark Souls", GenreId = "Action" }, new Game { GameId = "World of Warcraft", GenreId = "MMORPG" }, new Game { GameId = "Resident Evil 2", GenreId = "Survival" }, new Game { GameId = "Resident Evil 2", GenreId = "Horror" } }; var groupedList = list.GroupBy( g => g.GameId, g => g.GenreId, (key, group) => new { GameId = key, Genres = group.ToList() }) .ToList(); (在下面的屏幕截图中以红色墨水突出显示)“可触摸”的组件。但是,在该组件内部,我想要另一个具有自己的TouchableHighlight处理程序的组件(下面以蓝色墨水突出显示)。

我该如何实现?

grid with TouchableHighlight

1 个答案:

答案 0 :(得分:1)

您可以这样做:

<TouchableHighlight onPress={() => console.log("something 01")}>
    <View>
        //some code
        <TouchableHighlight onPress={() => console.log("something 02")}></TouchableHighlight>
        //some code
    </View>
</TouchableHighlight>