引入子组件报错



  • c75780ea-fa52-4fe6-92ae-12cd63104000-image.png

    父组件是这样
    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: 'Alex'
    }

    nameClick = () => {
    this.setState({ name: 'Joss' })
    }

    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;

    查了好多 最多的说法是更新taro-ui 可是我在node-modules里面没有找到 taro-ui
    我把父组件中引入的Child注释掉 就不报错了
    感觉还是子组件中 哪里不对


登录后回复