小编Ale*_*lex的帖子

如何在 React Native 中删除视图

我仍然很陌生,直到现在我仍然无法理解当用户单击特定按钮时如何删除视图。例如,假设我有以下代码块:

import React, { Component } from 'react'
import { AppRegistry, View, Text, TouchAbleOpacity } from 'react-native'

class Example extends Component {
    removeView(){
        // what should I do here?
    }

    render(){
        return (
            <View>
                <View> // View to be removed
                    <TouchAbleOpacity onPress={() => this.removeView()}>
                      <Text>Remove View</Text>
                    </TouchAbleOpacity>
                </View>
            </View>
        )
    }
}

AppRegistry.registerComponent('example', () => Example);
Run Code Online (Sandbox Code Playgroud)

如何以编程方式删除 View 元素?

android reactjs react-native

4
推荐指数
1
解决办法
7083
查看次数

标签 统计

android ×1

react-native ×1

reactjs ×1