【问题标题】:Why this component doesn't works?为什么这个组件不起作用?
【发布时间】:2019-04-19 14:47:18
【问题描述】:

我已经开始学习 react-native 并且我正在尝试创建一个组件,但是当我看到代码时出现了错误。有人知道为什么这个组件不工作吗?

Image of code

【问题讨论】:

    标签: android react-native mobile


    【解决方案1】:

    你需要像这样从'react'包中导入组件

    import React, { Component } from 'react'
    

    或者,你可以使用已经导入的 React 类中的 Component,像这样

       class MeuComponente extends React.Component {
         // your code here
       }
    

    两种解决方案是等价的

    【讨论】:

      【解决方案2】:

      你需要使用已经导入的 React 类中的Component,像这样:Component for React.Component

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-10-22
        • 2011-06-15
        • 1970-01-01
        • 2017-06-09
        • 1970-01-01
        • 2011-04-06
        • 2013-03-10
        相关资源
        最近更新 更多