子组件报错

来源:1-2 搭建Taro环境

六两1996

2020-07-10 17:35

Super expression must either be null or a function 

我怎么查都查不到 问题在哪

父组件是这样 

import React, { Component } from 'react'

import { View, Text, Button } from '@tarojs/components'

import './index.less'

import Child from './child.jsx';


export default class Index extends Component {


  state = {

    name: '林彦俊'

  }


  nameClick = () => {

    this.setState({ name: '尤长靖' })

  }


  render() {

    const { name } = this.state;

    return (

      <View className='index'>

        <Button onClick={this.nameClick}>更改名字</Button>

        <Text>{name}</Text>

        <Child name='857'/>

      </View>

    )

  }

}


子组件是这样 

import taro, { Component } from '@tarojs/taro';

import { View, Text } from '@tarojs/components'


class Child extends Component {


    render() {

        return (

            <View>

                <Text>子组件</Text>

                {this.props.name}

            </View>

        );

    }

}


export default Child;

http://img4.mukewang.com/5f0836330001515009260365.jpg

写回答 关注

1回答

  • 水若寒宇
    2020-07-20 23:20:30

    子组件的显示文本最好放置到text中试试

Taro多端框架开发外卖首页

Taro 一套代码多端运行的框架,带你掌握Taro开发基本语法,以及项目开发

22910 学习 · 82 问题

查看课程

相似问题